I have bug with real time IP camera.(when use Split Function) [closed]

asked 2016-02-09 02:09:53 -0600

Apple-B gravatar image

updated 2016-02-09 03:18:16 -0600

int main()
{ 
    cv::VideoCapture vcap;
    cv::Mat image;

    // This works on a D-Link CDS-932L
    const std::string videoStreamAddress = "http://admin:[email protected]/video.cgi?.mjpg";

    //open the video stream and make sure it's opened
    if(!vcap.open(videoStreamAddress)) {
        std::cout << "Error opening video stream or file" << std::endl;
        return -1;
    }
    int frame=0;
    while(1) {
        //cv::Mat image;
        if(!vcap.read(image)) {
            std::cout << "No frame" << std::endl;
            cv::waitKey();
        }
        cv::imshow("Camera Window", image);
        if(cv::waitKey(1) >= 0) break;
        printf("%d\n",frame);
        frame=frame+1;

    //Load the image
    //cv::Mat rgb_image = imread( "C:/Users/Yokkung/Desktop/project_combine/1201.png",CV_LOAD_IMAGE_COLOR);// test didnt connect camera
    cv::Mat rgb_image = image; //connect camera done
    int m = rgb_image.rows;
    int n = rgb_image.cols;
    cv::Size s = rgb_image.size();
    m = s.height;
    n = s.width;

    // Input Quadilateral or Image plane coordinates
    Point2f inputQuad[4]; 
    // Output Quadilateral or World plane coordinates
    Point2f outputQuad[4];
    // Lambda Matrix
    Mat lambda( 2, 4, CV_32FC1 );
    // Input and Output Image;
    Mat input, output;
    // Load the image
    input = rgb_image;

    // Set the lambda matrix the same type and size as input
    lambda = Mat::zeros( input.rows, input.cols, input.type());

    // The 4 points that select quadilateral on the input , from top-left in clockwise order
    // These four pts are the sides of the rect box used as input 
    inputQuad[0] = Point2f( 8.33,275.94);
    inputQuad[1] = Point2f( 359.36,193.1);
    inputQuad[2] = Point2f( 602.78,219.57);
    inputQuad[3] = Point2f( 361.07,433.1);  
    // The 4 points where the mapping is to be done , from top-left in clockwise order
    outputQuad[0] = Point2f( 100,400 );
    outputQuad[1] = Point2f( 100,75);
    outputQuad[2] = Point2f( 550,75);
    outputQuad[3] = Point2f( 550,400);

    // Get the Perspective Transform Matrix i.e. lambda 
    lambda = getPerspectiveTransform( inputQuad, outputQuad );
    // Apply the Perspective Transform just found to the src image
    warpPerspective(input,output,lambda,output.size() );
    rgb_image=output;
    Mat transformedII2 = (Mat_<double>(m,n)) ;
    transformedII2 = rgb_image;
    // Display input and output
    //imshow("Input",input);
    //imshow("Output",rgb_image); //USE rgb_image next section (Navigation and fire detection

    //Split HSV plane
    vector<Mat> channels;
    Mat hsv_image,h_image,s_image,v_image;
    cvtColor(rgb_image, hsv_image, CV_BGR2HSV); 
    split(hsv_image, channels); //channels[0], channels[1], channels[2] will contain your H, S, V respectively
 //   h_image = channels[0]; 
 //   s_image = channels[1];
    //v_image = channels[2];
    //imshow("V", v_image);
    //imshow("S", s_image);
    //imshow("H", h_image);
} //end capture every frame
}

Output debugger show below HEAP[testvs.exe]: Invalid address specified to RtlValidateHeap( 006F0000, 0455A358 ) testvs.exe has triggered a breakpoint.

The thread 0x110 has exited with code 0 (0x0).

The thread 0x12f8 has exited with code 0 (0x0).

The thread 0x16c4 has exited with code 0 (0x0).

The thread 0x16ec has exited with code 0 (0x0).

The thread 0x4fc has exited with code 0 (0x0).

The thread 0x1698 has exited with code 0 (0x0).

The thread 0xa1c has exited with code 0 (0x0).

The program '[3364] testvs.exe' has exited with code 0 (0x0).

edit retag flag offensive reopen merge delete

Closed for the following reason question is not relevant or outdated by sturkmen
close date 2020-10-07 13:28:26.273793

Comments

please try to reduce your code (and error msg) to the absolute minimum nessecary to reproduce the problem. this will also help you to seperate the issue.

also, please use the "10101" button to format your code correctly (as it is now, anyone will just shudder , and move on)

berak gravatar imageberak ( 2016-02-09 02:27:13 -0600 )edit
2

Thank you. my first time Ask Question.

Apple-B gravatar imageApple-B ( 2016-02-09 02:55:51 -0600 )edit
1

Best guess, add a waitKey(15); just behind the imshow("H", h_image); and your problems will be gone.

StevenPuttemans gravatar imageStevenPuttemans ( 2016-02-09 07:24:12 -0600 )edit
2

^^ @StevenPuttemans you missed the heap problem (and there's already a waitKey() in the loop)

berak gravatar imageberak ( 2016-02-09 08:02:57 -0600 )edit

Thank you very much. I already run real time. :)

Apple-B gravatar imageApple-B ( 2016-02-10 08:06:55 -0600 )edit