EXTRACTOBJECTS Procedure
Example 7.4 Crop and Save Object Detections in Multiple Rows
(View the complete code for this example.)
This example shows how to use the EXTRACTOBJECTS procedure to crop object detections and save them in multiple-row format. For more information, see the section Cropping Detected Objects.
The code in this example assumes that the mylib.coco_annotations table is loaded in advance. This table contains one image, and that image (see Figure 2) has two object detections that are annotated in COCO format (see Output 7.3.1).
The following statements crop the two object detections in the input image by using the annotations that are provided in COCO format. The resulting table, mylib.objects, contains cropped images that are saved in multiple rows when you specify the FORMAT= option in the OUTPUT statement.
proc extractobjects data=mylib.coco_annotations
coordinateformat=coco maxobjects=2 method=crop;
output out=mylib.objects format=multiplerows;
run;
The following PROC PRINT statement displays the mylib.objects table, which is generated by the previous statements:
proc print data=mylib.objects;
run;
Output 7.4.1 shows that the mylib.objects table has two rows and that image binaries are saved in the _image_ variable.
Output 7.4.1: The mylib.objects Table
| Obs | _image_ | _size_ | _path_ | _type_ |
|---|---|---|---|---|
| 1 | ... | 73881 | /path/to/birds.png | png |
| 2 | ... | 70798 | /path/to/birds.png | png |
Again, you can use the DISPLAYIMAGES procedure to display the cropped images.
proc displayimages data=mylib.objects;
run;
Output 7.4.2 shows the ODS output of PROC DISPLAYIMAGES.
Output 7.4.2: Cropped Objects
