由 c++ 和 opencv 生成的奇怪图像标题
Strange image title generated by c++ and opencv
下面是一个非常简单的例子,使用openCV显示2D矩阵。奇怪的是,图像标题无法正确显示。请问,有什么建议吗?
#include "stdafx.h"
#include "opencv2/highgui/highgui.hpp"
#include "opencv2/core/core.hpp"
#include "opencv2/highgui/highgui.hpp"
#include "opencv2/imgproc/imgproc.hpp"
#include <string>
#include <iostream>
using namespace cv;
using namespace std;
int main( int argc, const char** argv )
{
Mat M(200, 200, CV_8UC3, Scalar(0, 0, 255));
string Something ("Some text");
namedWindow("Hello", CV_WINDOW_AUTOSIZE);// Create a window for display.
imshow(Something, M);
waitKey(0);
return 0;
}
代码中存在问题,传递给 namedWindow 的字符串是窗口的标识符(不完全是标题)。
要将图像输出到窗口,imshow
需要以前创建的窗口的名称。我想你想使用你在namedWindow
中定义的那个.
正确的代码是这样的:
string Something ("Some text");
namedWindow(Something, CV_WINDOW_AUTOSIZE);// Create a window for display.
imshow(Something, M);
也许这更像是你喜欢做的事情?
变量 Something 是窗口的标识符。
相关文章:
- C++,OpenCV,尝试显示图像时"OpenCV(4.3.0) Error: Assertion failed (size.width>0 && size.height>0)"此错误
- 如何使用OpenCV将RBG图像转换为HSV,并将H、S和V值保存为C++中的3个独立图像
- OpenCV EqualizeHist()从彩色图像创建黑白图像
- 将"打开的CV图像"中的"颜色"转换为整数格式
- 为什么在Windows上的VS 2019和Clang 9中"size_t"在没有标题的情况下工作
- 平均图像时图像损坏
- 在C++中使用GDAL可以将图像的像素坐标转换为lat,long吗
- 如何将图像传输到c++(dll)中的缓冲区,然后在c#的缓冲区中读/写
- Vulkan验证层不断在VkQueuePresentKHR()上抛出图像布局错误
- 使用FFMPEG将RGB图像序列保存到.mp4时出现问题
- 将RGB图像保存为PPM格式
- 将图像添加到资源文件夹UWP C++
- C++:灰度位图标题和实时绘画+opencv图像处理
- 如何确定 BMP 图像是否包含来自标题的 BGR 或 BGRA 像素
- 标题文件用于OpenCV中的图像denoising
- 由 c++ 和 opencv 生成的奇怪图像标题
- 在c++中读取RAW图像或Do RAW图像具有标题
- Opencv C++;在标题中使用int显示多个图像
- 从原始标题和图像数据创建位图
- 从标题(宽度、高度等)获取图像信息,而无需打开它