在opencvc++中打开图像
IplImage Open Image in openCV c++
我有图片保存为1.jpg, 2.jpg和3.jpg在一个文件夹(在C:/images/result/template/)
我正在尝试加载所有的图像如下:
string link="C:/images/result/template/";
int i=1;
while (i<4)
{
link=link+i+".jpg";
IplImage* templat = cvLoadImage(link, 1);
IplImage* templat2 = cvCreateImage(cvSize(templat->width, templat->height),
IPL_DEPTH_8U, 1);
i++
}
然而,我得到错误。
错误C2678:二进制'+':找不到左操作数类型为'std::string'的操作符(或者没有可接受的转换)
您可以使用sprintf
或std::stringstream
加载一系列图像
下面是如何使用sprintf
:
char link[512];
int i=1;
while (i<4)
{
sprintf(link,"C:/images/result/template/%d.jpg",i);
IplImage* templat = cvLoadImage(link, 1);
IplImage* templat2 = cvCreateImage(cvSize(templat->width, templat->height),IPL_DEPTH_8U, 1);
i++
}
链接=链接+我+"jpg";
并不像你想象的那样——事实上我很惊讶它能编译。
p。您需要检查cvLoadImage()的返回,以检查它是否实际加载了任何东西。
pp。你应该使用cv::imread()
检查路径,当路径不正确时:link = null
试试这个
string link="C://images//result//template//"; //Please put '//' instead of '/'
int i=1;
while (i<4)
{
link=link+i+".jpg";
IplImage* templat = cvLoadImage(link.c_str(), 1); // instead of string, use char*
IplImage* templat2 = cvCreateImage(cvSize(templat->width, templat->height),IPL_DEPTH_8U,1);
i++; //put semi-colon
}
相关文章:
- 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图像"中的"颜色"转换为整数格式
- 平均图像时图像损坏
- 在C++中使用GDAL可以将图像的像素坐标转换为lat,long吗
- 如何将图像传输到c++(dll)中的缓冲区,然后在c#的缓冲区中读/写
- Vulkan验证层不断在VkQueuePresentKHR()上抛出图像布局错误
- 使用FFMPEG将RGB图像序列保存到.mp4时出现问题
- 将RGB图像保存为PPM格式
- 将图像添加到资源文件夹UWP C++
- 如何使用opencvc++拍摄动态视频图像和深度图像
- 在opencvc++中设置彩色图像中的像素(i,j)为黑色
- opencvc++图像导出到c#
- 在opencvc++中设置图像区域为零的最佳方法
- 在opencvc++中打开图像
- 如何确定感兴趣的区域,然后使用opencvc++裁剪图像
- opencvc++在阈值图像中查找移动
- 使用OpenCvC++中的原始图像作为掩码,从图像中删除徽标
- 水下图像增强使用opencvc++