2014-04-15 04:45:40 -0500 asked a question Kalman Filter to a ROI Hi! I have some problems to apply the Kalman filter to a ROI of a program I made. I am very interest in Kalman filter, because I want to reduce the noise when i am tracking the ROI. I started using the program published by Roy shown in http://www.morethantechnical.com/2011/06/17/simple-kalman-filter-for-tracking-using-opencv-2-2-w-code/ In the program the Kalman filter (2D) is used to track the mouse. I am trying to adapt the code for tracking a ROI. My ROI is defined: //ROI lado = 2*R; // R is the radius of a previously defined circle origen_x = (int) ( p[0] - lado/2.); // p[0] and p[1] are the coordinates of the center of the circle origen_y = (int) ( p[1] - lado/2.); I've tried to apply the Kalman filter this ROI: int main (int argc, char * const argv[]) { Mat img(500, 500, CV_8UC3) KalmanFilter KF(4, 2, 0); Mat_ state(4, 1); // (x, y, Vx, Vy) Mat processNoise(4, 1, CV_32F); Mat_ measurement(2,1); measurement.setTo(Scalar(0)); char code = (char)-1;  for(;;) namedWindow("kalman");  KF.statePre.at(0) = origen_x; /the x coordinate of my ROI KF.statePre.at(1) = origen_y; // the y coordinate of my ROI KF.statePre.at(2) = 0; //No info of the velocity KF.statePre.at(3) = 0; KF.transitionMatrix = *(Mat_(4, 4) << 1,0,0,0, 0,1,0,0, 0,0,1,0, 0,0,0,1); setIdentity(KF.measurementMatrix); setIdentity(KF.processNoiseCov, Scalar::all(1e-4)); setIdentity(KF.measurementNoiseCov, Scalar::all(1e-1)); setIdentity(KF.errorCovPost, Scalar::all(.1));  //randn(KF.statePost, Scalar::all(0), Scalar::all(0.1));  for(;;) {  // Point statePt(state(0),state(1));  Mat prediction = KF.predict(); Point predictPt(prediction.at(0),prediction.at(1)); measurement(0) = origen_x; measurement(1) = origen_y; Point measPt(measurement(0),measurement(1)); // generate measurement //measurement += KF.measurementMatrix*state; Mat estimated = KF.correct(measurement); Point statePt(estimated.at(0),estimated.at(1)); kalmanv.push_back(statePt); // plot points  #define drawCross( center, color, d ) \ line( img, Point( center.x - d, center.y - d ), \ Point( center.x + d, center.y + d ), color, 2, CV_AA, 0); \ line( img, Point( center.x + d, center.y - d ), \ Point( center.x - d, center.y + d ), color, 2, CV_AA, 0 )  img = Scalar::all(0); drawCross( statePt, Scalar(255,255,255), 5 ); drawCross( measPt, Scalar(0,0,255), 5 );  // drawCross( predictPt, Scalar(0,255,0), 3 ); // line( img, statePt, measPt, Scalar(0,0,255), 3, CV_AA, 0 ); // line( img, statePt, predictPt, Scalar(0,255,255), 3, CV_AA, 0 ); // randn( processNoise, Scalar(0), Scalar::all(sqrt(KF.processNoiseCov.at(0, 0)))); // state = KF.transitionMatrix*state + processNoise;  imshow( "kalman", img ); code = (char)waitKey(100); if( code > 0 ) break; }  i I know that is not complete, but I need some ideas and help to continue (I repeat that the program without the Kalman Filter works ok, I can detect and track a ROI, but I need to implement this filter to reduce the noise). Thaks ... 2014-04-11 09:38:34 -0500 commented question Histogram and backprojection windows, in black Hi! First, thanks for your comment. But that´s not the problem , I think. I don´t know if there is something wrong doing the backprojection, or what happens. In the next post I am gioing to shoy (if I can) a screenshot of what happens when I run the program. 2014-04-11 03:45:07 -0500 asked a question Histogram and backprojection windows, in black Hello: I have a problem: I made a program to detect a red circle, and once detected to track it with camshift. I tsuposed to work, but now I have a problem: when I run the program (with a video file), I can see the "normal"window (the window whit the video file) correctly, but the histogram window or the window with the backprojection mode are in black (sometimes i can see some white points, but it doesn´t work well). What can be the problem? What do you think? Where would you look? Ideas? Thanks!! EDITED: now you can see a screeshot of what happens when I run the program. the "Detection" window shows the input video (with some changes); in the "Filter" window should appear the backprojection of the tracked object (the red circle), but something is wrong, the only thing that you can see are some white points in the place of the tracked object; in the "histogram" window should appear the histogram (predominantly red), but neither appears. Where do you think that can be the problem? Ideas to star searching? Thanks!!!!!! 2014-04-11 02:08:29 -0500 asked a question camshift demo automatically Hi! I need your help. I am trying to test the camshift demo program that comes with the openCV samples. I want to make a change: in stead og calling "void onMouse (...)" to select with the mouse the object to track (basing on the colour of the object), I want to use something (maybe a "HaarClassifierCascade" ), to detect and track AUTOMATICALLY (I mean without using the mouse) something (for example, a logo, to need only 1 or to 2 "positive examples"). The problem is that I don´t know exactly what I have to do (something of create a xml files with the the positive and negative images). I know that is a veeeeeery general cuestion, but please, any idea is wellcome. Thanks in advance!! 2014-04-09 09:19:59 -0500 commented question Problem compiling Camshift in Ubuntu Thanks!!! It worked!! thank you Haris! 2014-04-09 04:21:01 -0500 received badge ● Editor (source) 2014-04-09 04:19:31 -0500 asked a question Aborted (core dumped) I have made a program that uses camshift. I am doing somethig wrong because the program runs a few secons but then I have an error: " OpenCV Error: Assertion failed (rect.width >=0 && rect.heigh >= 0 && rect.x >image->width && rect.y > image->heigh && (...) in cvSetImageROI, file/home/ubuntu/OpenCV-2.4.0/modules/core/src/array.cpp, line 3006 terminate called after throwing an instance of "cv::Exception" what(): /home/ubuntu/OpenCV-2.4.0/modules/core/src/array.cpp:3006:error: (-215) rect.width (...) Aborted (core dumped) " I don´t understand what is happening, how can I fix the error? Thanks! 2014-04-09 02:16:46 -0500 asked a question Problem compiling Camshift in Ubuntu Hi, I need your hepl. I´m new using this. I need to compile a main program in ubuntu (main.cpp, wrote in c++). Ihave no problem compiling programs that no depend on camshift, doing, for example: "g++ main.cpp -lopencv_core -lopencv_highgui -lopencv_imgproc -o main" But now, trying to compile a program that calls camshift, I have an error: "undefined reference to cvCamshift " I don´t know how what library I have to call! Pease, hepl! Thanks in advance!!