Hough, RANSAC, Kalman, issue with (Unhandled Expression )

asked 2015-10-22 19:57:09 -0500

husseinbmv gravatar image

updated 2015-10-22 22:44:00 -0500

berak gravatar image

Hello everyone, I am try to develop a lane detection and tracking program using opencv. I am having this annoying ERROR which is saying that there is undhandeled expression at a memory location

The main.cpp program is :

‪#‎include‬ <iostream>
#include <vector>
#include <opencv2/core/core.hpp>
#include <opencv2/highgui/highgui.hpp>
#include <opencv2/imgproc/imgproc.hpp>
#include "laneDetection.h"
#include "CKalmanFilter.h"
using namespace std;
using namespace cv;
int main(int argc, char** argv)
laneDetection detect;
int keypressed = 0;
IplImage *frame = NULL;
CvCapture *input_video2 = cvCreateFileCapture("road.avi");
Mat input_video = cvarrToMat(input_video2);
if(input_video.empty()){ //check if there is a frame
fprintf(stderr,"Error: Can not read from file\n\n\n\n");
return -1;}

vector<Vec2f> lines = detect.houghTransform();
Mat imgfinal = detect.drawLines(input_video,lines);
while(keypressed =!27){
frame = cvQueryFrame(input_video2);
Mat img2 = cvarrToMat(frame);
if (img2.empty()){
fprintf(stderr,"Error : Images has been finished\n\n\n\n");
return -1;
vector<Vec2f> lines2 = detect.houghTransform();
if (lines2.size() < 2)
imgfinal = detect.drawLines(img2,lines);
CKalmanFilter KF2(lines);
vector<Vec2f> pp = KF2.predict();
vector<Vec2f> lines2Final = KF2.update(lines2);
lines = lines2Final;
imgfinal = detect.drawLines(img2,lines2);
} //End of the loop
} //End of Main

image description

I am sure that there is no problem with CKalmanfilter.cpp and lanedetection.cpp

edit retag flag offensive close merge delete



please , first get rid of the outdated c-api stuff. you already shot your foot in line 2:

CvCapture *input_video2 = cvCreateFileCapture("road.avi");
Mat input_video = cvarrToMat(input_video2);

RRRRR, you can't just cast a Capture object to a cv::Mat !!

use cv::VideoCapture instead.

please all IplImage* and such must leave. then try again.

berak gravatar imageberak ( 2015-10-22 22:48:25 -0500 )edit

this seems like a bad idea, too:

vector<Vec2f> pp = KF2.predict();
vector<Vec2f> lines2Final = KF2.update(lines2);

the Mat <--> vector conversion is problematic, also, you can't expect to get the same number of lines consistently from HoughLines (this is more a conceptual problem)

berak gravatar imageberak ( 2015-10-22 23:19:09 -0500 )edit

Thank you @berak, but i have already done this before, string filename = "road.avi"; VideoCapture capture(filename); Mat frame,img2; capture >> frame;

but the same problem is keeping to show up every time,

husseinbmv gravatar imagehusseinbmv ( 2015-10-23 10:46:21 -0500 )edit