bethesirius / ChosunTruck

Euro Truck Simulator 2 autonomous driving solution
732 stars 104 forks source link

[master] Assertion failure when running in Debug mode #22

Closed zappybiby closed 7 years ago

zappybiby commented 7 years ago

This error occurs at startup while in Debug mode:

OpenCV Error: Assertion failed (src.checkVector(2, CV_32F) == 4 && dst.checkVect or(2, CV_32F) == 4) in cv::getPerspectiveTransform, file ...\opencv_sources\modules\imgproc\src\imgwarp.cpp, line 6353

This makes the program not run in Debug mode. This is a big problem for me, as Debug mode would allow for better debugging.

The program runs fine in Release mode.

zappybiby commented 7 years ago

Looking at some forums, this is caused by the wrong file type being used in the transformation.

See http://answers.opencv.org/question/18252/opencv-assertion-failed-for-perspective-transform/

simjaecheol commented 7 years ago

Have you tried this one? http://stackoverflow.com/questions/15683184/assertion-failed-when-im-trying-to-use-getperspectivetransform-on-android-ndk-t This is android opencv problems, but I think it looks very similar to your problem. I hope it works. :)

zappybiby commented 7 years ago

Where do we define the type of the mat in our master branch?

simjaecheol commented 7 years ago

In IPM::createMaps() in IPM.cpp, there are

m_mapX.create(m_dstSize, CV_32F); m_mapY.create(m_dstSize, CV_32F); ... m_invMapX.create(m_origSize, CV_32F); m_invMapY.create(m_origSize, CV_32F);

How about change CV_32F to CV_32FC2?

zappybiby commented 7 years ago

Still the same error :(

I have no idea

zappybiby commented 7 years ago

CV_32FC2 actually makes Release fail to work.

_origSize, _dstSize, _origPoints, _dstPoints are all size 4 according to the debugger. Not sure why its failing the assertion.

simjaecheol commented 7 years ago

Looking at CvType, CV_32FC2 contains x and y coordinates. (reference) In our case, however, only one coordinate is used.

float* ptRowX = m_mapX.ptr(j); ... ptRowX[i] = pt.x;

For this reason, I think there is an error in release mode.

I think CV_32FC1 is suitable in our case.

chi3236 commented 7 years ago

This is a little off-topic opinion, but if you execute the program which is built with debug mode, it will be REALLY slow.

At the early time of the project, I built the program with debug mode. Although the program did not have the steering function, I got less than 10 fps with Intel Haswell i7 processor.

zappybiby commented 7 years ago

Yep, debug disables the optimization parameters that Release has on by default.

CV_32FC1 still gives the error unfortunately.