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

조회 수: 8 (최근 30일)
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

채택된 답변

Sean de Wolski
Sean de Wolski 2013년 10월 9일
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')

추가 답변 (1개)

Dima Lisin
Dima Lisin 2013년 12월 24일
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?

카테고리

Help CenterFile Exchange에서 Structures에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by