By following this tutorial:
I created an XML configuration file, and a list of asymmetric circle grid images to run the camera calibration C++ sample. Everything is checked in here.
When I set board width to 5 and height to 4 I get this error:
terminate called after throwing an instance of 'cv::Exception'
what(): OpenCV(4.5.0-dev) /home/zero/opencv-master/modules/core/src/convert_c.cpp:112: error: (-215:Assertion failed) src.size == dst.size && src.channels() == dst.channels() in function 'cvConvertScale'
All the images are exactly the same, taken using Raspberri Pi camera in a sequence.
When I set board width to 4 and height to 3, I get this instead:
terminate called after throwing an instance of 'cv::Exception'
what(): OpenCV(4.5.0-dev) /home/zero/opencv-master/modules/calib3d/src/circlesgrid.cpp:1524: error: (-215:Assertion failed) h >= 2 && w >= 2 in function 'getCornerSegments'
Has anyone gotten this sample to work, or is it hopelessly broken? Someone created the same issue in OpenCV but it was never resolved:
https://github.com/opencv/opencv/issues/6503
The issue I linked in the original post was actually resolved some time later and contains the solution:
https://github.com/opencv/opencv/issues/6503
Run is OK if set config size_width and size_height with n - 1 and m - 1(n is number of columns in real board-size, m is number of rows in real board-size)
The issue was that width and height were not counted the way I assumed (unfortunately it was not clear from documentation how they were counted).
Apologies to everyone who commented!
Related
I am new to working with Promela and in particular SPIN. I have a model which I am trying verify and can't understand SPIN's output to resolve the problem.
Here is what I did:
spin -a untitled.pml
gcc -o pan pan.c
./pan
The output was as follows:
pan:1: VECTORSZ is too small, edit pan.h (at depth 0)
pan: wrote untitled.pml.trail
(Spin Version 6.4.5 -- 1 January 2016)
Warning: Search not completed
+ Partial Order Reduction
Full statespace search for:
never claim - (none specified)
assertion violations +
acceptance cycles - (not selected)
invalid end states +
State-vector 8172 byte, depth reached 0, errors: 1
0 states, stored
0 states, matched
0 transitions (= stored+matched)
0 atomic steps
hash conflicts: 0 (resolved)
I then ran SPIN again to try to determine the cause of the problem by examining the trail file. I used this command:
spin -t -v -p untitled.pml
This was the result:
using statement merging
spin: trail ends after -4 steps
#processes: 1
( global variable dump omitted )
-4: proc 0 (:init::1) untitled.pml:173 (state 1)
1 process created
According to this output (as I understand it), the verification is failing during the "init" procedure. The relevant code from within untitled.pml is this:
init {
int count = 0;
int ordinal = N;
do // This is line 173
:: (count < 2 * N + 1) ->
At this point I have no idea what is causing the problem since to me, the "do" statement should execute just fine.
Can anyone please help me in understanding SPINs output so I can remove this error during the verification process? The model does produce the correct output for reference.
You can simply ignore the trail file in this case, it is not relevant at all.
The error message
pan:1: VECTORSZ is too small, edit pan.h (at depth 0)
tells you that the size of directive VECTORSZ is too small to successfully verify your model.
By default, VECTORSZ has size 1024.
To fix this issue, try compiling your verifier with a larger VECTORSZ size:
spin -a untitled.pml
gcc -DVECTORSZ=2048 -o run pan.c
./run
If 2048 doesn't work too, try some more (increasingly larger) values.
I am processing a set of >3000 images of same size changing template every 300 images.
code snippet:
cv::Mat inTplate, cFrame, Cresult;
Cresult.create(resultH, resultW, IPL_DEPTH_32F);
cFrame(rect).copyTo(inTplate);
...
// this part executed for every frame
matchTemplate(cFrame, inTplate, Cresult, CV_TM_CCORR_NORMED);
minMaxLoc(Cresult, &minVal, &maxVal, &minLoc, &maxLoc, Mat());
rect = ( 250, 20, 1420, 1040); and resultH = 41; resultW = 501;
the very first time thru the code, the call to matchTemplate throws a memory fault that i believe comes from combase.dll and references an address that is not in the space for any of the three matrices: cFrame, inTplate or Cresult.
Also the sizes for the three matrices are consistent: cFrame 1080 rows X 1920 cols, inTplate 1040 rows X 1420 cols; Cresult is 41 rows X 501 cols. yes the first time inTplate is a region of cFrame; thereafter cFrame is the next image read in.
i verified that the answsers coming back from matchTemplate are correct -- the matching is correct. And the memory fault occurs ONLY on the very first call, not on any of the subsequent frames.
Am I doing something wrong or am i looking at a bug in OpenCV ?
thanks for taking the time.
A sort of answer:
I modified my call to matchTemplate to use a try ... catch block. but it wouldnt catch the exception.
Then I went into Debug | Windows | Exception Settings and turned off the checkbox for cv::Exception.
Now the program runs without stopping with a memory exception. It would seem that i have now enabled OpenCV to catch the exception and deal with it. So the underlying issue still exists but OpenCV is taking care of it. i would still like to understand why the exception is being thrown in the first place, though.
I'm trying to train some branch logos with haar_cascade. What I've done is, I've taken 2500 squared pictures of 500 x 500 to populate the samples for opencv_createsamples. Then I generate them as:
opencv_createsamples -info 'logo.info' -vec '../logo.vec' -bg '../Negatives/bg.txt' -w 24 -h 24 -num 2500
in my logo.info I've got lines which correspond to the relative path of every picture, with a 1 0 0 500 500 meaning "there's one object between (0,0) and (500, 500)"
then I train the cascade as:
opencv_traincascade -data 'cascade/' -vec '../logo.vec' -bg '../Negatives/bg.txt' -numPos 2500 -numNeg 3019 -numStages 25 -featureType LBP -w 24 -h 24
with these parameters:
PARAMETERS:
cascadeDirName: cascade/
vecFileName: ../logo.vec
bgFileName: ../Negatives/bg.txt
numPos: 2500
numNeg: 3019
numStages: 25
precalcValBufSize[Mb] : 256
precalcIdxBufSize[Mb] : 256
stageType: BOOST
featureType: LBP
sampleWidth: 24
sampleHeight: 24
boostType: GAB
minHitRate: 0.995
maxFalseAlarmRate: 0.5
weightTrimRate: 0.95
maxDepth: 1
maxWeakCount: 100
And I've got 2 kind of errors:
OpenCV Error: One of arguments' values is out of range (No components/input_variables is selected!) in cvPreprocessIndexArray, file /tmp/buildd/opencv-2.3.1/modules/ml/src/inner_functions.cpp, line 432
terminate called after throwing an instance of 'cv::Exception'
what(): /tmp/buildd/opencv-2.3.1/modules/ml/src/inner_functions.cpp:432: error: (-211) No components/input_variables is selected! in function cvPreprocessIndexArray
...
this errors uses to happen when you don't give a significant difference between your num of images and your -num parameter. So, let's try to give less 100!!
well, when I've adjusted the parameters to not to go out from the array, I get the same type of output than images, but I get this error:
OpenCV Error: Assertion failed (tempNode->left) in write, file /tmp/buildd/opencv-2.3.1/modules/traincascade/boost.cpp, line 628
terminate called after throwing an instance of 'cv::Exception'
what(): /tmp/buildd/opencv-2.3.1/modules/traincascade/boost.cpp:628: error: (-215) tempNode->left in function write
Aborted
I've tried:
Changing the destiny size of the images (24x24, 36x36...)
Changing the -mode parameter.
Trying to put a #positiveSamples < #negativeSamples and #positiveSamples > #negativeSamples
What I have to do, is training obligatory with LBP (not HAAR). Do anyone have any clue?
Thank you in advance.
Uninstalling and rebuilding OpenCV solved the problem.
I am trying to train a haar-like classifier for pedestrians in OpenCV using 3340 positive images and 1224 negative images. (in a .txt file I keep the negative image names i.e negatives(1).bmp, and in a txt file I keep the positives i.e. picture(1).bmp 1 0 0 64 128.
Actually positive examples are already cropped images of pedestrians so I only need specify one positive sample per image).
At some point during the training process it stops and says :
"Opencv Error: Assertion failed (elements_read==1)in unknown function, file c:\path\cvhaartraining.cpp, line 1858"
Any ideas as to what is causing this ?
this issue was answered by creater of the utility on the OpenCV DevZone site in June 2012.
To quote Maria:
The problem is that your vec-file has exactly the same samples count
that you passed in command line -numPos 979. Training application used
all samples from the vec-file to train 0-stage and it can not get new
positive samples for the next stage training because vec-file is over.
The bug of traincascade is that it had assert() in such cases, but it
has to throw an exception with error message for a user. It was fixed
in r8913.
-numPose is a samples count that is used to train each stage. Some already used samples can be filtered by each previous stage (ie
recognized as background), but no more than (1 - minHitRate) * numPose
on each stage. So vec-file has to contain >= (numPose + (numStages-1)
* (1 - minHitRate) * numPose) + S, where S is a count of samples from vec-file that can be recognized as background right away. I hope it
can help you to create vec-file of correct size and chose right numPos
value.
It worked for me. I also had same problem, I was following the famous tutorial on HAAR training but wanted to try the newer training utility with
-npos 7000 -nneg 2973
so i did following calcs:
vec-file has to contain >= (numPos + (numStages-1) * (1 - minHitRate) * numPos) + S
7000 >= (numPos + (20-1) * (1 - 0.999) * numPos) + 2973
(7000 - 2973)/(1 + 19*0.001) >= numPos
numPos <= 4027/1.019
numPos <= 3951 ~~ 3950
and used:
-npos 3950 -nneg 2973
It works. I also noticed that others have also had success with reducing numPos : here
This is somewhat of a follow up to a question posted earlier last month.
In porting my work, to the work computer, I'm experiencing some new convolution problem.
So, my kernel is 30x30 size and now OpenCV complains:
Assertion failed (templ.cols <= 17 && templ.rows <= 17) in convolve, file /home/jeffrey/opencv/src/modules/gpu/src/imgproc.cpp, line 1677
terminate called after throwing an instance of 'cv::Exception'
So far this is the only noticeable problem I'm getting with the port so far..
Is this new, is this normal?
i'm also getting 2 errors which are most likely unrelated, but worth mentioning
[swscaler # 0x9422b00]No accelerated colorspace conversion found.
This is likely ffmpeg error
but i'm also getting an error stating OpenGL version unsupported
Could this be the culprit?
Ok, the problem was simply a lack of CUFFT
Thank you