没有设置cvCreateImage(cvGetSize)

时间:2017-07-20 21:16:40

标签: c++ arrays opencv

好吧,我正在尝试解析文件夹中的所有图像并且工作正常,但是当我尝试使用过滤器创建一些图像,或者分解为HSV时,我会得到一些问题。

所以有一些代码

for (size_t i = 0; i < filenames.size(); ++i)
{
    cout << folder + filenames[i] << " #" << i << endl;
    cv::Mat src = cv::imread(folder + filenames[i]);

    if (!src.data) { //Protect against no file
        cerr << folder + filenames[i] << ", file #" << i << ", is not an image" << endl;
        continue;
    }
    cv::imshow("image", src);
    cv::waitKey(250); //For fun, wait 250ms, or a quarter of a second, but you can put in "0" for no wait or -1 to wait for keypresses
                      /* do whatever you want with your images here */
    std::string str1 = folder + filenames[i];
    char * kekable = new char[str1.size() + 1];
    std::copy(str1.begin(), str1.end(), kekable);
    kekable[str1.size()] = '\0'; // don't forget the terminating 0


// don't forget to free the string after finished using it
    Mat dst = src;
    IplImage iplDst(dst);

    hsv = cvCreateImage(cvGetSize(&iplDst), IPL_DEPTH_8U, 3);
    h_plane = cvCreateImage(cvGetSize(&iplDst), IPL_DEPTH_8U, 1);
    s_plane = cvCreateImage(cvGetSize(&iplDst), IPL_DEPTH_8U, 1);
    v_plane = cvCreateImage(cvGetSize(&iplDst), IPL_DEPTH_8U, 1);
    delete[] kekable;

当我开始解析时出现错误 -

  

OpenCV错误:cvGetSize中的错误参数(数组应为CvMat或IplImage),文件C:\ build \ master_winpack-build-win64-vc14 \ opencv \ modules \ core \ src \ array.cpp,第1255行

我尝试了很多解决方案,但是我无法理解如何以正确的方式放置这个尺寸,即使是我需要工作的标志也会感激

0 个答案:

没有答案