Assertion Failed during opencv_createsamples

asked 2018-11-06 13:13:24 -0600

SH13567890 gravatar image

updated 2018-11-06 14:27:08 -0600

I am trying to create a vec file from my positive image samples. I'm using the latest version of Opencv. The command I am using is this:

opencv_createsamples -info Positive.info -num 3750 -w 24 -h 24 -vec Positive.vec

All my images are bigger than 24x24, so I don't believe that that is the issue. I've tried searching online, but I don't find anyone with this error while doing the createsamples command. The output that I get when I run that is this:

Info file name: Positive.info
Img file name: (NULL)
Vec file name: Positive.vec
BG  file name: (NULL)
Num: 3750
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
Show samples: FALSE
Width: 24
Height: 24
Max Scale: -1
RNG Seed: 12345
Create training samples from images collection...
OpenCV: terminate handler is called! The last OpenCV error is:
OpenCV(4.0.0-alpha) 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\master_winpack-build-win64-vc15\opencv\modules\core\src\matrix.cpp, line 465

This is my first time using opencv, so I'm very unclear as to what this error is. Anyone have any experience with this or can point me in the right direction to correcting the error?

Edit: Here is the first few lines of my Positive.info file:

full_path\positives\7bc1acac12bbc9876db252efc0249c5863c9de9b620eb8745c5d1202.jpg 1 54 54 362 362 
full_path\positives\c1705114e4e13be2b0a8d4a214d59bbd7d8427cc7adadd3811712cd0.jpg 1 275 275 1835 1835
 full_path\positives\d103070d5cf33bd0b51f47dc2116ffdb764fba589b715858ca6415b6.png 1 36 36 351 351 
full_path\positives\8789913eb072be66371cedf7bf6ec1ce08780923e84847006730508e.jpg 1 42 42 282 282 
full_path\positives\b12785be8686004a39b9a32a2c0af56c75e650a8b93785979d797b2c.jpg 1 45 45 300 300 
full_path\positives\bef84d8d43a9fb5f119ca7e94863fd16a3e92206414e68bd18607b49.jpg 1 22 22 152 152 
full_path\positives\eef8e58c523263dc2371a899fa80686d50362e803e6c1d4b0c718cf1.jpg 1 41 41 275 275 
full_path\positives\df236ca99ff5e618a971bee4599e16672b5ded618c8b77a3b2a90216.jpg 1 75 75 501 501

The path to the files is correct.

edit retag flag offensive close merge delete

Comments

please show the first few lines of your Positive.info

berak gravatar imageberak ( 2018-11-06 14:18:38 -0600 )edit
1

@berak Updated.

SH13567890 gravatar imageSH13567890 ( 2018-11-06 14:27:39 -0600 )edit

please don't use backslashes there, but forward ones, even on windows.

i can only guess here, but it's one of:

  • path problem
  • image not loaded / invalid
  • bounding box does not fit
berak gravatar imageberak ( 2018-11-07 01:08:22 -0600 )edit

@berak Could you explain what you mean by "bounding box does not fit". I will try the other things you suggested. Thank you.

SH13567890 gravatar imageSH13567890 ( 2018-11-07 08:06:49 -0600 )edit

the error complains about a roi out of bounds, right ?

so the resp. Mat was either empty, or too small

also have a look at the src code, recompiling it with CV_VERBOSE defined will output a lot of information

also (if it's within your skills), simply try to debug it ....

berak gravatar imageberak ( 2018-11-07 08:13:20 -0600 )edit

I'll take a look. Thanks.

SH13567890 gravatar imageSH13567890 ( 2018-11-07 08:16:24 -0600 )edit

have a look here

(that's where your assert is coming from. so either src empty() or roi too large.)

berak gravatar imageberak ( 2018-11-07 08:28:11 -0600 )edit

and again, the way the filename is parsed there: NO single backslashes (use 2 of them or forwar ones) or spaces in the filename allowed !

berak gravatar imageberak ( 2018-11-08 02:50:18 -0600 )edit

I'll be looking at this later today, and I'll try those things.

SH13567890 gravatar imageSH13567890 ( 2018-11-08 08:19:33 -0600 )edit

I have the same problem too. Could you please help me. I dont understand how ı can solve this problem from your comments. could you please give me detail to solve this error

abasak96 gravatar imageabasak96 ( 2019-05-21 14:28:33 -0600 )edit