Opencv imshow is showing weird image

asked 2018-12-11 19:57:05 -0500

lehoangphuc86 gravatar image

I am trying to use opencv to display image series which are captured continuously by gphoto in Ubuntu (to calibrate camera). However, i am getting an weird output that is mixed between the desired image and current window. Please help.

image description

Finding chessboard code

    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);

        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 code

    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 ;
edit retag flag offensive close merge delete


Try to check the data variable, to see if Gphoto captured a correct image...

Probably the bug is during capture or conversion, not imshow

kbarni gravatar imagekbarni ( 2018-12-12 01:36:27 -0500 )edit

Thanks for your suggestion. it is strange that there is no problem with the saved image from data variable.

lehoangphuc86 gravatar imagelehoangphuc86 ( 2018-12-12 02:25:59 -0500 )edit