Ask Your Question

MuathGH's profile - activity

2017-09-30 09:42:12 -0600 received badge  Notable Question (source)
2016-11-29 04:38:17 -0600 received badge  Popular Question (source)
2014-11-19 02:25:16 -0600 received badge  Student (source)
2013-07-18 05:14:12 -0600 commented answer coordinates of detected target

Unhandled exception at 0x000007fefd42a49d in test_For_opencv2_3.exe: Microsoft C++ exception: cv::Exception at memory location 0x002bd810..

same thing , i've created the matrix but still get this error

2013-07-18 05:04:39 -0600 commented answer coordinates of detected target

ok , i applied the findContours function on the foreground image and boundingRect : cv::findContours(fore,contours,CV_RETR_EXTERNAL,CV_CHAIN_APPROX_NONE); cv::boundingRect(contours);

but every time i try to run the program , this happens : Unhandled exception at 0x000007fefd42a49d in test_For_opencv2_3.exe: Microsoft C++ exception: cv::Exception at memory location 0x0019de50..

2013-07-18 02:59:04 -0600 received badge  Editor (source)
2013-07-18 02:49:38 -0600 asked a question coordinates of detected target

hel

hello , im trying to recover the coordination of a detected target and print it , im not expert in openCV neither C++ , this is my first code and i really need you're help , here's the code:

 #include "stdafx.h"
#include <highgui.h>
#include <opencv2/video/background_segm.hpp>
#include<opencv2/opencv.hpp>
#include<vector>
#include<opencv2\imgproc\imgproc.hpp>
#include <cv.h>
#include <ostream>
#include<ostream>

using namespace std;

int _tmain(int argc, _TCHAR* argv[])
{


    cv::BackgroundSubtractorMOG2 bg;
    bg.bShadowDetection=false;
    bg.nmixtures=3;
    bg.history=100;
    bg.varThreshold=10; 
    cv::Mat frame;
    cv::Mat fore;
    cv::Mat back;


    CvCapture* capture  = cvCaptureFromCAM(0); // capture from video device 


    cvNamedWindow("Orignal", CV_WINDOW_AUTOSIZE); // create a window to display the images
      cvNamedWindow("Processed", CV_WINDOW_AUTOSIZE); // create a window to display the images

    while(1) {

        frame=cvQueryFrame(capture);   // Grabs and returns a frame from a 
        bg.operator()(frame,fore);
        bg.getBackgroundImage(back);
        cv::erode(fore,fore,cv::Mat()); // to clear the noise   
        cv::dilate(fore,fore,cv::Mat()); // to smooth the objecty


        cv::imshow("Orignal",frame);
        cv::imshow("Processed",fore);

       if(cvWaitKey(10)==27) // to exit the loop using ESCP 

        break;
    }
 return 0;
}

so the detected object is in fore matrix , i need to get its X,Y position printed out .. is it possible ?