The output of objectDetector in Simulink

6 views (last 30 days)
Jamie on 7 Oct 2023
Answered: Debraj Maji on 9 Nov 2023
I am now working with the example intelligent-bin-picking-example-with-simulink
After the installation and configuration, when i start to run in simulink, the following error occurred:
Error in 'IntelligentBinPicking/Object Detector/Draw Shapes': The Pts input must be an M-by-4 matrix. Each row specifies a different rectangle and is of the form [x y width height].
Error in port widths or dimensions. 'output 1' of 'IntelligentBinPicking/Object Detector/Data Type Conversion' is a matrix with a maximum size of [8x5].
function bboxes = objectDetector(image)
isSim ='sfun');
simSupported = false;
useExtrinsic = isSim && ~simSupported;
[bboxes] = deep.blocks.internal.objectDetector(image, 'C:\Users\jamie\Documents\MATLAB\intelligent-bin-picking-example-with-simulink\Perception\trainedYOLOv4DetectorSimGazebo_cuboid.mat', useExtrinsic, {'Threshold', 0.5, 'SelectStrongest', false}, {'NumStrongest', 8, 'RatioType', 'Union'}, 8, true, false, false);
It turns out the objectDetector output a Mx5 matrix instead of Mx4, I wonder if there is a way to control the output bboxes shape?

Answers (1)

Debraj Maji
Debraj Maji on 9 Nov 2023
Hi @Jamie,
I see that you are trying to detect objects using objectDetector method. The output provided by the detector is defined in spatial coordinates as an M-by-5 numeric matrix with rows of the form [xctr yctr xlen ylen yaw], where:
  • “M” is the number of rotated rectangles.
  • “xctr" and “yctr” specify the center of the rectangle.
  • “xlen” specifies the width of the rectangle, which is its length along the x-axis before rotation.
  • “ylen” specifies the height of the rectangle, which is its length along the y-axis before rotation.
  • yaw specifies the rotation angle in degrees. The rotation is clockwise-positive around the center of the bounding box.
One possible way to control the output matrix is by using the PredictedBoxType” function. When the PredictedBoxType” is "axis-aligned", the object detector will train and perform inference on only axis-aligned bounding boxes. If it is set to "rotated", the object detector will train and perform inference on only rotated bounding boxes. This property is to be set when the object is created.
You may go through the following MathWorks documentation link to learn more about the “objectDetector” function:




Community Treasure Hunt

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

Start Hunting!