Ask Your Question

coredump's profile - activity

2016-12-03 13:22:18 -0600 received badge  Scholar (source)
2016-12-03 08:23:17 -0600 commented answer matchTemplate determine match

Still a little confused ... So I use the normalize (...) function followed by the minMaxLoc (...) as shown below:

Mat result;
double minVal, maxVal;
Point  minLoc, maxLoc, matchLoc;
double thresholdMatch = 0;

matchTemplate(frame, template_img, result, CV_TM_SQDIFF_NORMED);

normalize(result, result, 0, 1, NORM_MINMAX, -1, Mat());
minMaxLoc(result, &minVal, &maxVal, &minLoc, &maxLoc, Mat());

std::cout << "minVal: " << minVal << endl;
std::cout << "minLoc: " << minLoc.x <<  " maxLoc: " << minLoc.y << endl;

The output looks like this:

// not found minLoc: 429 maxLoc: 512 minVal: 0 minLoc: 429 maxLoc: 512

// found minLoc: 58 maxLoc: 257 minVal: 0

The question is what should I match on MinLoc ?, assuming I don't know where the match is ?

2016-12-02 17:37:14 -0600 asked a question matchTemplate determine match

I am looking for a way to determine if a match was found, when calling this function:

Mat result;

matchTemplate(frame, template_img, result, CV_TM_SQDIFF_NORMED);

I have seen many examples of receiving a match drawing a square over the matched area and displaying it. I just want to know if it matched in a Boolean sense (Yes it matched, No it didn't)

2016-12-02 17:32:15 -0600 commented question cvQueryFrame returns rotated image

Still has the same problem

Mat frame, gray;
VideoCapture video(1); // 1 = web cam , -1 = autodetect , 0 = default

if(video.isOpened())
{
    int key = 0;
    do
    {
        video >> frame;
        if(frame.empty())
        {
            break;
        }

        imshow("Frame Captured", frame);

        cvtColor(frame, gray, CV_BGR2GRAY);

        (*pattern_cb)(gray);

        key = waitKey(10);
    } while((char)key != 27); // press ESC to exit
}
2016-12-01 22:08:38 -0600 asked a question cvQueryFrame returns rotated image

I am using a MacBook Pro OS X version 10.12.1 with an external USB Web Camera. If I look at an image in photo booth with the external web camera the image is correct. However when I capture frames from the same web cam and display it, the image shows up rotated 90 degrees clockwise. What am I doing wrong ?

Here is the code :

CvCapture *capture = 0;
capture = cvCaptureFromCAM(1); // 1 = web cam , -1 = autodetect , 0 = default
if (!capture)
{
    fprintf(stderr, "!!! Cannot open initialize webcam!\n" );
    return;
}

// Create a window for the video
cvNamedWindow("Frame Captured", CV_WINDOW_AUTOSIZE);

IplImage* frame = 0;
char key = 0;
while (key != 27) // ESC
{
    frame = cvQueryFrame(capture);
    if(!frame)
    {
        fprintf( stderr, "!!! cvQueryFrame failed!\n" );
        break;
    }

    // Display frame
    cvShowImage("Frame Captured", frame);

    // Exit when user press ESC
    key = cvWaitKey(10);
}

// Free memory
cvDestroyWindow("result");
cvReleaseCapture(&capture);

}