Problem with example motempl.cpp

asked 2015-04-08 02:52:32 -0500

LBerger gravatar image

updated 2015-04-08 02:53:58 -0500


I want to execute example motempl.cpp in module optflow. I have got an exception :

Unhandled exception at at 0x754E812F in optflow-example-motempl.exe: Microsoft C++ exception: cv::Exception at memory location 0x0011ECDC. This exception occurs after calling norm at line 123 of motempl.cpp :

count = norm( silh, 0, NORM_L1, 0 ); // calculate number of points within silhouette ROI

CV_Assert( _src1.sameSize(_src2) && _src1.type() == _src2.type() ) is 0 in cv::norm (line 3320 in opencv-master\modules\core\src\stat.cpp). _src1 is an array with size 0,0 in cv::norm. Before call parameters are good. Now I have found this link with an example of motion tracking. If I delete line 123 and I write like in this example

count = norm(silh, NORM_L2, noArray());

There is no exception now. As I am not specialist of motion tracking I don't know If I can change this line. My questions are :

Have you got an exception in this example?

If yes Is it a good modification to solve exception and keep good result in this example?

Thanks for your help

edit retag flag offensive close merge delete


wow, what a horror, it seems, noone has checked this sample for a long time... ;)

yes, i can reproduce your error.

what's most frightening me here, is that there seems to be a conversion from int (0, 2nd arg) to InputArray !

i'd try : count = norm(silh, NORM_L1); (why change the type of the norm to L2 ?)

berak gravatar imageberak ( 2015-04-08 03:28:46 -0500 )edit

for the reference, -

you probably should send a pull request with your fix.

berak gravatar imageberak ( 2015-04-08 03:32:59 -0500 )edit

@berak As this bug is already known I don't need to send a pull

LBerger gravatar imageLBerger ( 2015-04-08 07:07:32 -0500 )edit

^^ but his fix is bad. (it does not need a 2nd, zero Mat for this)

(well, yes, you don't need to make another issue at least)

berak gravatar imageberak ( 2015-04-08 07:12:08 -0500 )edit

As I say I'm not an expert of motion but on my webcam I understand results if I write

count = norm(silh_roi, NORM_L1);

instead of

count = norm( silh,  NORM_L1)

I need to understand all functions but may be you can give your opinion?

LBerger gravatar imageLBerger ( 2015-04-08 07:46:39 -0500 )edit

nice find !

i think, that is more, what was originally meant there (even given the comment there).

the python demo is also doing this.

berak gravatar imageberak ( 2015-04-08 08:00:12 -0500 )edit

I have tried a "pull request" for this example but I have got some problem. It's not the post subject.... In this example a circular buffer of size N can be found at line 63 (buf.resize(N);). I don't undestand the size N. it seems that a buffer of size 2 is enough. In python example there is no buffer. Current frame and previous frame are used to get difference between frames. Is it right? regions must be clear in the loop.

LBerger gravatar imageLBerger ( 2015-04-10 15:33:38 -0500 )edit

@berak I have done a pull request for this error in c++ code Now must I wait an answer accepted or rejected?

LBerger gravatar imageLBerger ( 2015-04-28 13:40:54 -0500 )edit

just wait, don't get too nervous, good things take a while.

(if they got any objections, they'll tell you.)

berak gravatar imageberak ( 2015-04-28 13:47:48 -0500 )edit

please see dikay's comment. there was a lot of 'line noise' in your commit due to using tabs, so it's a bit difficult to spot your 'real' changes.

again, imho, you're on the right track. they do not bite anyone. no fear.

berak gravatar imageberak ( 2015-04-28 14:00:23 -0500 )edit