0

I am trying to run the following command in my VB Code terminal

C:\Ankit\VirEnv\opencv\build\x64\vc14\bin\opencv_createsamples.exe -info C:\Ankit\VirEnv\pos.txt  -w 20 -h 20 -num 1000 -vec pos.vec

my pos.txt file looks like this

Pos.tex

My output

Info file name: C:\Ankit\VirEnv\pos.txt
Img file name: (NULL)
Vec file name: pos.vec
BG  file name: (NULL)
Num: 1000
BG color: 0
BG threshold: 80
Invert: FALSE
Max intensity deviation: 40
Max x angle: 1.1
Max y angle: 1.1
Max z angle: 0.5
Max z angle: 0.5
Show samples: FALSE
Width: 20
Height: 20
Max Scale: -1
RNG Seed: 12345
Create training samples from images collection...
Unable to open image: C:\Ankit\VirEnv\C:\Ankit\VirEnv\Test\Positive\opencv_frame_0.png
OpenCV: terminate handler is called! The last OpenCV error is:
OpenCV(3.4.16) Error: Assertion failed (0 <= roi.x && 0 <= roi.width && roi.x + roi.width <= m.cols && 0 <= roi.y && 0 <= roi.height && roi.y + roi.height <= m.rows) in cv::Mat::Mat, file C:\build\3_4_winpack-build-win64-vc14\opencv\modules\core\src\matrix.cpp, line 751

But I get this error:

OpenCV(3.4.16) Error: Assertion failed (0 <= roi.x && 0 <= roi.width && roi.x + roi.width <= m.cols && 0 <= roi.y && 0 <= roi.height && roi.y + roi.height <= m.rows) in cv::Mat::Mat, file C:\build\3_4_winpack-build-win64-vc14\opencv\modules\core\src\matrix.cpp, line 751 

I don't know what is wrong, as far I know the file created using opencv_annotation has all the right bounding rectangle coordinates still the error shows up. I am using following this video This link and this open cv documentation https://docs.opencv.org/3.4/dc/d88/tutorial_traincascade.html

Ankit_Gunner
  • 123
  • 10
  • Maybe an empty line at the end of the file or an illegal line where the box leaves the image borders? Try to find the problem by systematically adding or removing lines to/from the txt file. For example start with a single line. If that fails already, check the image dimensions and roi. It it works, add 50% of the samples and test again. – Micka Aug 26 '22 at 17:45
  • 1
    Ok, error is already printed: "Unable to open image: C:\Ankit\VirEnv\C:\Ankit\VirEnv\Test\Positive\opencv_frame_0.png" you see the wrong path string? – Micka Aug 26 '22 at 17:46
  • Ya I see the wrong path, thank you for point it out. so to solve it i tried to run the code in '(env) PS C:\> ' but now its says Unable to open file: pos.vec – Ankit_Gunner Aug 26 '22 at 17:59
  • 1
    Search for how entries and relative pathes have to be. There should be a few SO questions and blog entries about that. – Micka Aug 26 '22 at 18:30
  • 1
    @Micka thank you for you help, I found out path of pos.txt should have been just the file name instead of the whole path. – Ankit_Gunner Aug 26 '22 at 18:31

0 Answers0