Createsamples.exe: Error Code -9 [closed]

asked 2017-03-10 15:34:14 -0600

Davaaron gravatar image

updated 2017-03-11 08:53:34 -0600

Hi there,

as I finished creating my info.txt file containg the absolute paths to the images and the rectangle information of my desired objects to be detected, I just ran

opencv_createsamples.exe -info C:\Software\training\file.txt -vec C:\Software\training\samples.vec -w 20 -h 20

Unfortunaley I get an error code -9, saying:

OpenCV Error: Unknown error code -9 () in cvSetImageROI, file C:\build\master_winpack-build-win64-vc14\opencv\modules\core\src\array.cpp, line 3021

Anyone knows what's that about? Further it says it's not able to open my image, which is in a .jpg format. The funny thing is, that the specified location (C:\build\master_winpack-build-win64-vc14....) doesn't even exist. Not even in the opencv-folder. So is this a mess by opencv (like bad handling of paths)?

I'd be glad about some help. As always, the documentation of opencv doesn't give me any hint about what to do.

edit retag flag offensive reopen merge delete

Closed for the following reason question is not relevant or outdated by sturkmen
close date 2020-10-12 17:02:07.202916

Comments

berak gravatar imageberak ( 2017-03-11 09:01:00 -0600 )edit

if cvSetImageROI give you an error you are probably defining a bounding box that is outside your image region boundaries. Make sure your annotations are actually all within the image dimensions. Second possibility is that the path is incorrect. Third is that your paths are defined by a single backslash, which is an escape char in windows and should be replaced by double backslashes. Also OpenCV cannot handle spaces in image path locations, so avoid that.

StevenPuttemans gravatar imageStevenPuttemans ( 2017-03-11 14:21:49 -0600 )edit

Thanks for the answer. So let's break this down a bit. The data specified in the annotation text file is "C:\Users\myUsername\Pictures\positive\9336923.1.jpg 1 47 18 121 155". How could the bounding box be outside of the image? So it's obviously that the backslash is the reason. How could I change this now, afterwards? Usually, Windows uses a single backslash as path separator (or escape in programming), but reading from a file won't be a problem for Java, e.g. What about the dot (not for extension) ? Is that a problem, too?

Davaaron gravatar imageDavaaron ( 2017-03-11 20:03:21 -0600 )edit

Still not working. Why is opencv even that crap and undocumented? Because it's "open source" (yes, in quotes)? I'm delighted..

Davaaron gravatar imageDavaaron ( 2017-03-14 14:50:04 -0600 )edit

Actually your way of reacting is far from helping you... double backslash issues is not related to OpenCV, but to the windows backend, there is no issue at all with this on Linux based systems. That being said, I know of multiple people that are able to use the createsample tool without issue, so it probably is not that crappy ...

StevenPuttemans gravatar imageStevenPuttemans ( 2017-03-15 05:34:14 -0600 )edit