OpenCV IMShow显示奇怪的图像

时间:2018-11-28 02:50:38

标签: c++ linux opencv imshow

我正在尝试使用opencv显示在Ubuntu中由gphoto连续捕获的图像系列(以校准相机)。但是,我得到了一个奇怪的输出,该输出混合在所需的图像和当前窗口之间。

Image1

查找棋盘代码

camera.Capture(image,true); // capture image from gphoto
while(successes<numBoards) // check if the number of boards meets
{
    cvtColor(image, gray_image, CV_BGR2GRAY);
    bool found = findChessboardCorners(image, board_sz, corners, CV_CALIB_CB_ADAPTIVE_THRESH | CV_CALIB_CB_FILTER_QUADS);

    if(found)
    {
        cornerSubPix(gray_image, corners, Size(11, 11), Size(-1, -1), TermCriteria(CV_TERMCRIT_EPS | CV_TERMCRIT_ITER, 30, 0.01));
        drawChessboardCorners(gray_image, board_sz, corners, found);
    }
    imshow("Camera", image.clone());
    imshow("Camera_gray", gray_image.clone());
    int key = waitKey(30);
    camera.Capture(image,true);
}

camera.Capture代码

    void GphotoCapture::Capture(Mat &image, bool isToCalibrate){
    char    *data;
    unsigned long size;
    capture_to_memory(camera, context, (const char**)&data, &size);
    std::vector<unsigned char> ImVec(data, data + size);
    Mat ImMat;
    ImMat = imdecode(ImVec, 1); // convert data in memory to Mat
    image=ImMat ;
}

0 个答案:

没有答案