Privileged instruction

asked 2013-11-24 21:18:16 -0500

cedric100 gravatar image

updated 2013-11-25 04:59:50 -0500

Hi, I am new to OpenCV and I tried my first coding. It is about an object tracking that I entirely copied from the following video.https://www.youtube.com/watch?v=2i2bt-YSlYQ&feature=youtube_gdata_player

The webcam is working, but, there is no video displayed. Instead, the following message appears: Unhandled exception at 0x02312a3b in Tracker_1.exe: 0xC0000096: Privileged instruction.

Could anyone help me? I have no idea what happens.

Here is the coding.

// Tracker_1.cpp

#include<opencv/cvaux.h>
#include<opencv/highgui.h>
#include<opencv/cxcore.h>

#include<stdio.h>
#include<stdlib.h>

/////////////////////////////:
int main(int argc, char* argv[])
{
    CvSize size640x480 = cvSize(640, 480);   // use a 640 x 480 size for all windows =, also make sure your webcam is set to 640x480 !!

    CvCapture* p_capWebcam;  // we will assign our web cam videostream to this later . . .

    IplImage* p_imgOriginal;  // pointer to an image structure, this will be the input image from webcam.
    IplImage* p_imgProcessed; // pointer to an image structure, this will be the processed image.
                              /* IPL is short for Intel Image Processing Librart, this is the structure used in OpenCV.1.x to work with images */

    CvMemStorage* p_strStorage;  // Necessary storage variable to pass into cvHoughCircles()

    CvSeq* p_seqCircles;         // Pointer to an OpenCV sequence, will be returned by cvHoughCircles() and will contain all circles.
                                 // Call cvGetSeqElem(p_seqCircles, i) will return a 3 element array of the ith circle (see next variable).

    float* p_fltXYRadius;        // Pointer to a 3 element array floats.
                                 // [0] => x position of detected object.
                                 // [1] => y position of detected object.
                                 // [2] => Radius of detected object.

    int i;                       // Loop counter.
    char charCheckForEscKey;     // Char for checking key press (Esc exits program).

    p_capWebcam = cvCaptureFromCAM(0);  // 0 => use lst webcam, may have to change to a different number if you have multiple cameras.

    if(p_capWebcam == NULL)             // If capture was not successful . . .
    {
        printf("error: capture is NULL /n"); // Eror message to standard out . . .
        getchar();                           // getchar() to pause for user see message.
        return(-1);                          // Exit program.
    }
    // Declare 2 windows.
    cvNamedWindow("Original", CV_WINDOW_AUTOSIZE);  // Original image from webcam.
    cvNamedWindow("Processed", CV_WINDOW_AUTOSIZE); // The processed image we will use dor detectiing circles.

    p_imgProcessed = cvCreateImage(size640x480,     // 640 x 480 pixels (CvSize struct from earlier)
                                   IPL_DEPTH_8U,    // 8-bit color depth.
                                   1);              // 1 channel (grayscale), if this was a color image, use 3

    while(1)                                        // For each frame . . .
    {
        p_imgOriginal = cvQueryFrame(p_capWebcam);  // Get fram from webcam.

        if(p_imgOriginal == NULL)                   // If frame was not captures succesfully . . .
        {
            printf("Error: frame is NULL \n");      // Error message to std out.
            getchar();
            break;
        }

        cvInRangeS(p_imgOriginal,                   // function input.
                   CV_RGB(175, 0, 0),               // min filtering value (if color is greater thar or equal to this)
                   CV_RGB(256, 100, 100),           // max filtering value (if color is less than this)
                   p_imgProcessed);                 // function output.

        // Smooth the processed image, this will make it easier for the next function to pick out the circles.
        cvSmooth(p_imgProcessed,                    // Function input.
                 p_imgProcessed,                    // Function output.
                 CV_GAUSSIAN,                       // Use Gaussian filter (average nearby pixels, with the closest pixels weighted more).
                 9,                                 // Smoothing filter window width.
                 9);                                // Smoothing filter window height.

        // Fill sequential structure with all circles in processed image.
        p_seqCircles = cvHoughCircles(p_imgProcessed,   // Input image, nothe ...
(more)
edit retag flag offensive close merge delete

Comments

Even I am facing the same error.. Please help

Bushra gravatar imageBushra ( 2014-07-08 05:07:56 -0500 )edit