【问题标题】:opencv c++ HSV image channel separation exceptionopencv c++ HSV图像通道分离异常
【发布时间】:2014-07-08 16:20:16
【问题描述】:

我知道这个问题已经被问过很多次了,我正在尝试实现他们的答案,但它导致我的代码出现异常。

操作系统:Windows 7 OpenCV:2.4.9

这是我的代码:

#include "stdafx.h"

#include <iostream>
#include <stdio.h>
#include <stdlib.h>
#include "opencv2/highgui/highgui.hpp"
#include "opencv2/imgproc/imgproc.hpp"

using namespace cv;
using namespace std;

 int main( int argc, char** argv )
 {
    VideoCapture cap(0); //capture the video from webcam

    if ( !cap.isOpened() )  // if not success, exit program
    {
         cout << "Cannot open the web cam" << endl;
         return -1;
    }

   Mat imgHSV;
   _sleep(100); //give the camera a chance to wake up
    while (true)
    {
        Mat imgOriginal;
        bool success = cap.read(imgOriginal);
         if (!success) //if not success, break loop
        {
             cout << "Cannot read a frame from video stream" << endl;
             break;
        }



   cvtColor(imgOriginal, imgHSV, COLOR_BGR2HSV); //Convert the captured frame from BGR to HSV
       vector<Mat> hsv_planes;
   split( imgHSV, hsv_planes );
//hsv_planes[0] // H channel
//hsv_planes[1] // S channel
//hsv_planes[2] // V channel
  imshow(thresholded_window, hsg_planes[2]); //show the S channel
        if (waitKey(30) == 27) //wait for 'esc' key press for 30ms. If 'esc' key is pressed, break loop
       {
            cout << "esc key is pressed by user" << endl;
            break; 
       }
    }

   return 0;
}

在分割线上抛出异常:“TrackColour.exe 中 0x62B978C9 (opencv_core249.dll) 处的未处理异常:0xC0000005:访问冲突写入位置 0xFEEEFEEE。”

【问题讨论】:

    标签: opencv hsv


    【解决方案1】:

    我发现了我的问题,以防其他人发生这种情况。

    在 VS 中,我正在进行调试构建,但我正在链接到 opencv 的非调试版本。请注意,在我的错误消息 opencv_core249 中,它应该是 opencv_core249d(注意“d”)。我更新了我的 CV 链接以使用调试库并且它可以工作。

    其他 opencv 调用使用错误的库执行良好,拆分必须是唯一的。

    【讨论】:

      猜你喜欢
      • 2014-01-27
      • 2016-07-23
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-05-27
      • 2020-10-27
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多