Ask Your Question

Revision history [back]

Opencv imshow is showing weird 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 ;