how do i use objectdetectortraingdata function? in matlab

The objectDetectorTrainingData function is used to prepare training data for object detection models. It requires the following inputs:

  1. positiveInstances: an array containing objectDetectorTrainingData objects created from binary or color images of positive instances of the object(s) you want to detect
  2. negativeImages: an array of negative images that do not contain the object(s) you want to detect
  3. trainCascadeObjectDetector option-value pairs, which can include the false positive rate, number of stages, and minimum detection window size.

Here is an example of how to use this function in MATLAB:

main.m
positiveInstances = objectDetectorTrainingData(gTruth); % gTruth is a ground truth object
negativeFolder = fullfile(matlabroot,'toolbox','vision','visiondata',...
            'nonObjectImages');
negativeImages = imageDatastore(negativeFolder);

% Set detector training options
options = trainingOptions('sgdm','MiniBatchSize', 4, ...
    'PositiveFraction', 0.75, 'MaxEpochs', 10);

% Train detector
detector = trainFasterRCNNObjectDetector(positiveInstances, negativeImages, options);
486 chars
12 lines

This code trains a Faster R-CNN object detector using positive anchor boxes and negative images. In this example, the objectDetectorTrainingData function is used to create the positiveInstances variable from a ground truth object, and negative images are stored in the negativeFolder. The trainFasterRCNNObjectDetector function is used to train the detector using the training options specified.

related categories

gistlibby LogSnag