issue constructing structure with valid field names for traincasca​deobjectde​tector

1 view (last 30 days)
Hello All,
I am attempting to train my own cascade object detector via the computer vision toolboxes' trainCascadeObjectDetector function and following the extensive help files and examples. This is proving to be rather difficult however (impossible even). trainCascadeObjectDetector takes an array of structs called positiveInstances in the help file. It describes the structure as having a field of the image file name as a string, and the values as a bounding box around the ROI. After much head scratching, I have found the root of my problem on the help file for struct:
Valid field names begin with a letter, and can contain letters, digits, and underscores.
No punctuation! How can I specify a string of a file name without punctuation for the extension? i.e. "image0001.jpg"
I feel like I am missing something important...
I am running 2012a on a linux machine.
Any help is much appreciated,
Ian

Accepted Answer

Sean de Wolski
Sean de Wolski on 9 Oct 2013
No. Fieldnames have to be valid MATLAB variable names. If you need to create them on the fly, you can use genvarname:
genvarname('image0001.jpg')
And isvarname to check beforehand:
isvarname('image0001.jpg')

More Answers (1)

Dima Lisin
Dima Lisin on 24 Dec 2013
There seems to be some confusion here. There are two fields in the struct. The name of the first field is 'imageFilename', and its value is the file name, such as 'image0001.jpg'. The name of the second field is 'objectBoundingBoxes', and its value is the M-by-4 matrix of the form [x, y, w, h].
So, you do not need to turn the file names into field names. Does this make sense?

Categories

Find more on Image Processing and Computer Vision in Help Center and File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!