EXTRACTOBJECTS Procedure
Example 7.3 Visualize Detections in YOLO Format
(View the complete code for this example.)
This example shows how to use the EXTRACTOBJECTS procedure to visualize object detections that are provided in YOLO format. For more information about annotation formats, see the section Supported Image Annotation Formats.
The following PROC FEDSQL statement adds the object detections in YOLO format to the image table. It is assumed that the input image is loaded in the mylib.images table.
proc fedsql sessref=mysess;
create table yolo_annotations as
select
*,
2 as "_nObjects_",
'object1' as "_Object0_",
0.2343 as "_Object0_x", 0.2232 as "_Object0_y",
0.4486 as "_Object0_width", 0.3437 as "_Object0_height",
'object2' as "_Object1_",
0.6473 as "_Object1_x", 0.4241 as "_Object1_y",
0.4397 as "_Object1_width", 0.3281 as "_Object1_height"
from
images;
quit;
Note: These statements create the mylib.yolo_annotations table by using the image binaries and metadata from the mylib.images table and adding annotation variables in YOLO format. Ensure that the following variables are specified for each detected object in the mylib.yolo_annotations table, where N denotes the Nth detected object:
_ObjectN__ObjectN_x_ObjectN_y_ObjectN_width_ObjectN_height
The following PROC PRINT statement displays the mylib.yolo_annotations table, which is generated by the previous statements:
proc print data=mylib.yolo_annotations;
run;
Output 7.3.1 shows the mylib.yolo_annotations table.
Output 7.3.1: The mylib.yolo_annotations Table
| Obs | _width_ | _height_ | _image_ | _size_ | _path_ | _type_ | _id_ | _nObjects_ | _Object0_ | _Object0_x | _Object0_y | _Object0_width | _Object0_height | _Object1_ | _Object1_x | _Object1_y | _Object1_width | _Object1_height |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 1 | 448 | 448 | ... | 457024 | /path/to/birds.png | png | 1 | 2 | object1 | 0.2343 | 0.2232 | 0.4486 | 0.3437 | object2 | 0.6473 | 0.4241 | 0.4397 | 0.3281 |
The following statements highlight the two object detections in the input image by using the annotations that are provided in YOLO format. The resulting table, mylib.objects, contains images that have visualizations.
proc extractobjects data=mylib.yolo_annotations
coordinateformat=yolo maxobjects=2 method=highlight;
output out=mylib.objects;
run;
Output 7.3.2 shows the output image with two extracted objects.
Output 7.3.2: Visualization of Object Detections
