Problem with example motempl.cpp
Hi,
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
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 ?)for the reference, - http://code.opencv.org/issues/4269#no...
you probably should send a pull request with your fix.
@berak As this bug is already known I don't need to send a pull
^^ 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)
As I say I'm not an expert of motion but on my webcam I understand results if I write
instead of
I need to understand all functions but may be you can give your opinion?
nice find !
i think, that is more, what was originally meant there (even given the comment there).
the python demo is also doing this.
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.
@berak I have done a pull request for this error in c++ code https://github.com/Itseez/opencv_cont.... Now must I wait an answer accepted or rejected?
just wait, don't get too nervous, good things take a while.
(if they got any objections, they'll tell you.)
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.