Clear Filters
Clear Filters

trainingRCNNdetector inputs other than tables

1 view (last 30 days)
I have an image array 256x256x100 to train a net with but all of the examples of trainingRCNNdetector input a table of individual file locations. How do I put in the frames directly, I have no folder of files? I have all of the toolboxes.

Answers (1)

T.Nikhil kumar
T.Nikhil kumar on 26 Sep 2023
Hey Daniel,
I understand that you want to use the frames of images instead of storing it in file locations for the training of an RCNN network using the “trainRCNNObjectDetector” function.
In trainRCNNObjectDetector function, the “trainingData” argument must be of the type “table”. Each entry of this “trainingData” table must have the image specified as a file with path only. The images can be in any format supported by the “imread” function.
Therefore, you cannot directly use these images in 3D array format with the trainRCNNObjectDetector” function.
You can follow the below steps to convert the 3D array of images to individual image files programmatically. Assuming you have a 3D image array called imageArray with dimensions (height, width, number of frames):
Step 1: Choose an output directory where you want to save the individual image files.
Step 2: Loop through each frame in the 3D array and save it as an individual image file using the “imwrite” function.
Refer to the following code snippet:
% Specify the output directory where you want to save the images
outputDirectory = 'path_to_output_directory';
%Loop through the image array
for i = 1:size(imageArray, 3)
% Extract the current frame
currentFrame = imageArray(:, :, i);
% Define the filename for the current frame using any naming convention
filename = fullfile(outputDirectory, sprintf('frame%d.png', i));
% Save the current frame as an image file (e.g., PNG)
imwrite(currentFrame, filename);
end
You can refer to the below documentation link to understand more about Training Object Detector Using R-CNN Deep Learning.
You can refer to the below documentation to understand more about trainRCNNObjectDetector” function
To know about all the formats supported by the ”imread” function, please refer
I hope this helps!

Community Treasure Hunt

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

Start Hunting!