Analyze and Visualize Detected Video Objects Using Keras and ImageAI

Read part 1 here

Last month, I wrote an article that explored the nature of videos and how to use Keras, OpenCV, and ImageAI to easily run object detection code on videos and a live camera feed. If you haven’t read this article, kindly visit this link, as it will be very helpful in understanding what will be covered in this post.

The previous article walked us through installing all the Python dependencies, downloading the detection models, running the code on both video files and a live camera feed, and saving the detected video.

In this article, we’ll be working on obtaining detection data for every single frame and second of a video file. We’ll also visualize the detected video and plot the analytical data generated in real-time by our detection code.

As we’ve learned from the previous tutorial, all we need to detect objects in a video is our YOLOv3 model and our 9 lines of code as seen below:

from imageai.Detection import VideoObjectDetection
import os

execution_path = os.getcwd()

detector = VideoObjectDetection()
detector.setModelTypeAsYOLOv3()
detector.setModelPath( os.path.join(execution_path , "yolo.h5"))
detector.loadModel()

video_path = detector.detectObjectsFromVideo(input_file_path=os.path.join( execution_path, "traffic-mini.mp4"),
                                output_file_path=os.path.join(execution_path, "traffic_mini_detected_1")
                                , frames_per_second=29, log_progress=True)
print(video_path)

The code above will detect only the objects in the video and save a new video file with the objects visually identified with bounding boxes. The ImageAI library allows you to retrieve analytical data from each frame and second of a detected video file or live camera feed in real-time.

To obtain this data, we’ll have to define a function that receives a number of parameters, and then parse the name of the function into the .detectObjectsFromVideo function. In the sample below, we’re going to retrieve analytical data from the video for every frame detected.

First, we need import the ImageAI detection class and create a function that will retrieve the analytical data of the detection for each frame processed.

from imageai.Detection import VideoObjectDetection
import os



execution_path = os.getcwd()

def forFrame(frame_number, output_array, output_count):


    print("Frame Number : " , frame_number)
    print("Output for each object : ", output_array)
    print("Output count for unique objects : ", output_count)
    print("------------END OF A FRAME --------------")

In the function above, with the name forFrame, we’re expecting 3 parameters to be sent into it every time a video frame is detected. Then the parameters are printed to the console so that we can observe what’s contained in each one.

Now we’ll include the above code in our normal video detection code with just the difference of setting the parameter value per_frame_function to the name of our function forFrame in the detectObjectsFromVideo function. We’ll be running this code on a 5-second video that you can download via this link. However, you can use any other video for this sample. See the full code below:

from imageai.Detection import VideoObjectDetection
import os



execution_path = os.getcwd()

def forFrame(frame_number, output_array, output_count):


    print("Frame Number : " , frame_number)
    print("Output for each object : ", output_array)
    print("Output count for unique objects : ", output_count)
    print("------------END OF A FRAME --------------")


video_detector = VideoObjectDetection()
video_detector.setModelTypeAsYOLOv3()
video_detector.setModelPath(os.path.join(execution_path, "yolo.h5"))
video_detector.loadModel(detection_speed="fast")


video_detector.detectObjectsFromVideo(input_file_path=os.path.join(execution_path, "traffic-mini.mp4"), save_detected_video=False ,  frames_per_second=20, per_frame_function = forFrame, minimum_percentage_probability=30)

Let’s review our detectObjectsFromVideo function. You’ll notice a couple things:

  • We specified only the input_file_path and not the output_file_path. This is because we don’t intend to save the detected video, and to do this, we set the parameter save_detected_video to False.
  • To obtain the analytical data and execute our function every time a frame in the video is detected, we specify the parameter per_frame_function to the name of our function, forFrame.

When we run this code, every time a frame in the video is processed for detection, we’ll see the result produced in the console.

Frame Number :  1

Output for each object :  [{'box_points': (431, 66, 532, 147), 'name': 'bus', 'percentage_probability': 52.76165008544922}, {'box_points': (523, 88, 692, 256), 'name': 'bus', 'percentage_probability': 94.58253383636475}, {'box_points': (178, 77, 466, 369), 'name': 'bus', 'percentage_probability': 98.9076554775238}, {'box_points': (654, 256, 685, 329), 'name': 'motorcycle', 'percentage_probability': 53.046077489852905}, {'box_points': (87, 269, 143, 359), 'name': 'motorcycle', 'percentage_probability': 96.98374271392822}, {'box_points': (46, 128, 104, 153), 'name': 'car', 'percentage_probability': 34.1302216053009}, {'box_points': (484, 146, 520, 184), 'name': 'car', 'percentage_probability': 37.20671534538269}, {'box_points': (88, 70, 134, 95), 'name': 'car', 'percentage_probability': 37.31269836425781}, {'box_points': (714, 203, 765, 300), 'name': 'car', 'percentage_probability': 38.89184594154358}, {'box_points': (501, 46, 581, 79), 'name': 'car', 'percentage_probability': 51.00165009498596}, {'box_points': (583, 25, 647, 52), 'name': 'car', 'percentage_probability': 54.11568284034729}, {'box_points': (440, 210, 479, 335), 'name': 'car', 'percentage_probability': 65.9595787525177}, {'box_points': (612, 58, 687, 101), 'name': 'car', 'percentage_probability': 69.79938745498657}, {'box_points': (123, 167, 204, 267), 'name': 'car', 'percentage_probability': 79.7627329826355}, {'box_points': (728, 204, 847, 311), 'name': 'car', 'percentage_probability': 86.23504042625427}, {'box_points': (461, 196, 506, 298), 'name': 'car', 'percentage_probability': 97.82060384750366}, {'box_points': (654, 256, 685, 329), 'name': 'bicycle', 'percentage_probability': 32.098063826560974}, {'box_points': (165, 91, 543, 345), 'name': 'person', 'percentage_probability': 53.5614013671875}, {'box_points': (760, 179, 790, 210), 'name': 'person', 'percentage_probability': 57.70213603973389}, {'box_points': (704, 141, 726, 196), 'name': 'person', 'percentage_probability': 58.933085203170776}, {'box_points': (324, 197, 391, 265), 'name': 'person', 'percentage_probability': 70.21441459655762}, {'box_points': (626, 181, 652, 267), 'name': 'person', 'percentage_probability': 83.7773084640503}, {'box_points': (81, 213, 145, 337), 'name': 'person', 'percentage_probability': 86.72647476196289}, {'box_points': (698, 200, 728, 307), 'name': 'person', 'percentage_probability': 90.71170091629028}, {'box_points': (651, 214, 688, 323), 'name': 'person', 'percentage_probability': 97.00838327407837}]

Output count for unique objects :  {'motorcycle': 2, 'bus': 3, 'car': 11, 'bicycle': 1, 'person': 8}

The above data generated by the detection process and retrieved by our function might look like a maze to you. Allow me to break it down:

i. The first value sent into our function is the frame number, and in the console, we have Frame Number : 1

ii. The second value sent into our function is an array of dictionaries, with each dictionary corresponding to all objects detected in the frame and their properties. Each dictionary contains the name of the object, percentage probability, and box points that define the location of the object in the image frame. Below are samples of 2 dictionaries contained in the data generated:

{‘box_points’: (698, 200, 728, 307), ‘name’: ‘person’, ‘percentage_probability’: 90.71170091629028},

{‘box_points’: (651, 214, 688, 323), ‘name’: ‘person’, ‘percentage_probability’: 97.00838327407837}

iii. The third value sent into our function is the a dictionary of all the objects detected in the frame and the number of instances of each of the object detected.

{‘motorcycle’: 2, ‘bus’: 3, ‘car’: 11, ‘bicycle’: 1, ‘person’: 8}

This data will be sent and our function executed for every frame processed for detection in the video.

We can also obtain analytical data for every second of the video. All we need to do is create a new function and parse the function name into the detectObjectsFromVideo function. See the full code below:

from imageai.Detection import VideoObjectDetection
import os

execution_path = os.getcwd()

def forSeconds(second_number, output_array, output_count_array, average_counting):
    print("Second Number : ", second_number)
    print("Array for the outputs of each frame ", output_array)
    print("Array for output count for unique objects in each frame : ", output_count_array)
    print("Output average count for unique objects in the last second: ", average_counting)
    print("------------END OF A SECOND --------------")


video_detector = VideoObjectDetection()
video_detector.setModelTypeAsYOLOv3()
video_detector.setModelPath(os.path.join(execution_path, "yolo.h5"))
video_detector.loadModel(detection_speed="fast")

video_detector.detectObjectsFromVideo(input_file_path=os.path.join(execution_path, "traffic-mini.mp4"), save_detected_video=False ,  frames_per_second=20, per_second_function=forSeconds , minimum_percentage_probability=30)

In the above code, we created a function with the name forSeconds. Notice that the parameters expected in the function are 4, unlike the forFrame function that has 3. This is because the analytical data sent for every second contains all object dictionaries for each frame, a unique object count for each frame, and an average unique object count for the all the number of frames contain in the last second.

When we run the code above, we should see the following result in the console:

Second Number :  1

Array for the outputs of each frame  [[{'percentage_probability': 52.76165008544922, 'name': 'bus', 'box_points': (431, 66, 532, 147)}, {'percentage_probability': 94.58253383636475, 'name': 'bus', 'box_points': (523, 88, 692, 256)}, {'percentage_probability': 98.9076554775238, 'name': 'bus', 'box_points': (178, 77, 466, 369)}, {'percentage_probability': 53.046077489852905, 'name': 'motorcycle', 'box_points': (654, 256, 685, 329)}, {'percentage_probability': 96.98374271392822, 'name': 'motorcycle', 'box_points': (87, 269, 143, 359)}, {'percentage_probability': 34.1302216053009, 'name': 'car', 'box_points': (46, 128, 104, 153)}, {'percentage_probability': 37.20671534538269, 'name': 'car', 'box_points': (484, 146, 520, 184)}, {'percentage_probability': 37.31269836425781, 'name': 'car', 'box_points': (88, 70, 134, 95)}, {'percentage_probability': 38.89184594154358, 'name': 'car', 'box_points': (714, 203, 765, 300)}, {'percentage_probability': 51.00165009498596, 'name': 'car', 'box_points': (501, 46, 581, 79)}, {'percentage_probability': 54.11568284034729, 'name': 'car', 'box_points': (583, 25, 647, 52)}, {'percentage_probability': 65.9595787525177, 'name': 'car', 'box_points': (440, 210, 479, 335)}, {'percentage_probability': 69.79938745498657, 'name': 'car', 'box_points': (612, 58, 687, 101)}, {'percentage_probability': 79.7627329826355, 'name': 'car', 'box_points': (123, 167, 204, 267)}, {'percentage_probability': 86.23504042625427, 'name': 'car', 'box_points': (728, 204, 847, 311)}, {'percentage_probability': 97.82060384750366, 'name': 'car', 'box_points': (461, 196, 506, 298)}, {'percentage_probability': 32.098063826560974, 'name': 'bicycle', 'box_points': (654, 256, 685, 329)}, {'percentage_probability': 53.5614013671875, 'name': 'person', 'box_points': (165, 91, 543, 345)}, {'percentage_probability': 57.70213603973389, 'name': 'person', 'box_points': (760, 179, 790, 210)}, {'percentage_probability': 58.933085203170776, 'name': 'person', 'box_points': (704, 141, 726, 196)}, {'percentage_probability': 70.21441459655762, 'name': 'person', 'box_points': (324, 197, 391, 265)}, {'percentage_probability': 83.7773084640503, 'name': 'person', 'box_points': (626, 181, 652, 267)}, {'percentage_probability': 86.72647476196289, 'name': 'person', 'box_points': (81, 213, 145, 337)}, {'percentage_probability': 90.71170091629028, 'name': 'person', 'box_points': (698, 200, 728, 307)}, {'percentage_probability': 97.00838327407837, 'name': 'person', 'box_points': (651, 214, 688, 323)}], [{'percentage_probability': 50.66089630126953, 'name': 'bus', 'box_points': (432, 66, 532, 147)}, {'percentage_probability': 92.68375039100647, 'name': 'bus', 'box_points': (517, 98, 664, 252)}, {'percentage_probability': 98.67194294929504, 'name': 'bus', 'box_points': (178, 76, 467, 371)}, {'percentage_probability': 63.17805051803589, 'name': 'motorcycle', 'box_points': (654, 256, 686, 330)}, {'percentage_probability': 97.82216548919678, 'name': 'motorcycle', 'box_points': (83, 270, 140, 360)}, {'percentage_probability': 30.546724796295166, 'name': 'car', 'box_points': (713, 203, 764, 300)}, {'percentage_probability': 32.98213183879852, 'name': 'car', 'box_points': (88, 91, 135, 117)}, {'percentage_probability': 33.24395716190338, 'name': 'car', 'box_points': (486, 146, 521, 184)}, {'percentage_probability': 40.1374876499176, 'name': 'car', 'box_points': (89, 70, 134, 94)}, {'percentage_probability': 41.547733545303345, 'name': 'car', 'box_points': (47, 128, 104, 152)}, {'percentage_probability': 53.91727685928345, 'name': 'car', 'box_points': (501, 46, 581, 79)}, {'percentage_probability': 54.121023416519165, 'name': 'car', 'box_points': (583, 25, 647, 52)}, {'percentage_probability': 62.2473418712616, 'name': 'car', 'box_points': (439, 210, 478, 336)}, {'percentage_probability': 78.94790172576904, 'name': 'car', 'box_points': (611, 58, 688, 101)}, {'percentage_probability': 85.86116433143616, 'name': 'car', 'box_points': (123, 166, 203, 266)}, {'percentage_probability': 87.2096598148346, 'name': 'car', 'box_points': (729, 203, 848, 311)}, {'percentage_probability': 97.73063063621521, 'name': 'car', 'box_points': (461, 196, 507, 298)}, {'percentage_probability': 58.54947566986084, 'name': 'person', 'box_points': (704, 141, 726, 194)}, {'percentage_probability': 58.691924810409546, 'name': 'person', 'box_points': (162, 91, 545, 346)}, {'percentage_probability': 61.393773555755615, 'name': 'person', 'box_points': (760, 178, 790, 210)}, {'percentage_probability': 66.57586097717285, 'name': 'person', 'box_points': (323, 198, 391, 265)}, {'percentage_probability': 69.3754255771637, 'name': 'person', 'box_points': (3, 186, 47, 344)}, {'percentage_probability': 83.55879783630371, 'name': 'person', 'box_points': (630, 181, 658, 265)}, {'percentage_probability': 91.77078604698181, 'name': 'person', 'box_points': (75, 216, 145, 329)}, {'percentage_probability': 92.81125664710999, 'name': 'person', 'box_points': (698, 199, 728, 307)}, {'percentage_probability': 96.7454195022583, 'name': 'person', 'box_points': (651, 214, 688, 323)}], [{'percentage_probability': 52.399444580078125, 'name': 'bus', 'box_points': (431, 67, 532, 146)}, {'percentage_probability': 95.12508511543274, 'name': 'bus', 'box_points': (516, 98, 663, 253)}, {'percentage_probability': 98.33334684371948, 'name': 'bus', 'box_points': (177, 76, 465, 370)}, {'percentage_probability': 56.716084480285645, 'name': 'motorcycle', 'box_points': (654, 257, 687, 331)}, {'percentage_probability': 93.46223473548889, 'name': 'motorcycle', 'box_points': (80, 271, 138, 361)}, {'percentage_probability': 30.52329421043396, 'name': 'car', 'box_points': (88, 91, 135, 117)}, {'percentage_probability': 40.396592020988464, 'name': 'car', 'box_points': (87, 69, 134, 95)}, {'percentage_probability': 45.35970985889435, 'name': 'car', 'box_points': (46, 128, 105, 153)}, {'percentage_probability': 51.67117714881897, 'name': 'car', 'box_points': (501, 45, 580, 79)}, {'percentage_probability': 56.248849630355835, 'name': 'car', 'box_points': (583, 24, 648, 52)}, {'percentage_probability': 71.46394848823547, 'name': 'car', 'box_points': (611, 59, 688, 101)}, {'percentage_probability': 79.78141903877258, 'name': 'car', 'box_points': (439, 213, 477, 336)}, {'percentage_probability': 84.68828201293945, 'name': 'car', 'box_points': (121, 166, 200, 266)}, {'percentage_probability': 88.71477246284485, 'name': 'car', 'box_points': (727, 203, 848, 310)}, {'percentage_probability': 97.4938154220581, 'name': 'car', 'box_points': (459, 197, 506, 297)}, {'percentage_probability': 42.178988456726074, 'name': 'bicycle', 'box_points': (654, 257, 687, 331)}, {'percentage_probability': 46.43590748310089, 'name': 'person', 'box_points': (760, 180, 790, 209)}, {'percentage_probability': 55.89331388473511, 'name': 'person', 'box_points': (322, 199, 390, 266)}, {'percentage_probability': 57.30406641960144, 'name': 'person', 'box_points': (157, 92, 552, 343)}, {'percentage_probability': 66.43943786621094, 'name': 'person', 'box_points': (703, 139, 725, 196)}, {'percentage_probability': 67.57064461708069, 'name': 'person', 'box_points': (1, 185, 44, 347)}, {'percentage_probability': 82.50755071640015, 'name': 'person', 'box_points': (626, 183, 652, 265)}, {'percentage_probability': 89.95848894119263, 'name': 'person', 'box_points': (72, 218, 142, 330)}, {'percentage_probability': 94.41657662391663, 'name': 'person', 'box_points': (698, 199, 728, 310)}, {'percentage_probability': 97.69037365913391, 'name': 'person', 'box_points': (650, 214, 689, 322)}], [{'percentage_probability': 60.35170555114746, 'name': 'bus', 'box_points': (432, 66, 533, 147)}, {'percentage_probability': 96.42831683158875, 'name': 'bus', 'box_points': (515, 95, 665, 253)}, {'percentage_probability': 98.74972701072693, 'name': 'bus', 'box_points': (176, 74, 465, 374)}, {'percentage_probability': 52.34766602516174, 'name': 'motorcycle', 'box_points': (654, 258, 687, 331)}, {'percentage_probability': 95.24673819541931, 'name': 'motorcycle', 'box_points': (76, 270, 131, 363)}, {'percentage_probability': 35.73530912399292, 'name': 'car', 'box_points': (88, 90, 134, 116)}, {'percentage_probability': 38.84355127811432, 'name': 'car', 'box_points': (90, 69, 132, 94)}, {'percentage_probability': 43.991684913635254, 'name': 'car', 'box_points': (46, 127, 108, 151)}, {'percentage_probability': 44.90320384502411, 'name': 'car', 'box_points': (500, 44, 579, 78)}, {'percentage_probability': 51.36361122131348, 'name': 'car', 'box_points': (583, 24, 647, 51)}, {'percentage_probability': 73.58211874961853, 'name': 'car', 'box_points': (439, 214, 476, 336)}, {'percentage_probability': 74.82874989509583, 'name': 'car', 'box_points': (611, 58, 688, 102)}, {'percentage_probability': 86.94114089012146, 'name': 'car', 'box_points': (727, 203, 848, 311)}, {'percentage_probability': 87.72221207618713, 'name': 'car', 'box_points': (119, 165, 199, 266)}, {'percentage_probability': 97.60699272155762, 'name': 'car', 'box_points': (460, 196, 506, 297)}, {'percentage_probability': 51.41611099243164, 'name': 'bicycle', 'box_points': (654, 258, 687, 331)}, {'percentage_probability': 57.557642459869385, 'name': 'person', 'box_points': (761, 180, 790, 209)}, {'percentage_probability': 58.13015699386597, 'name': 'person', 'box_points': (331, 198, 382, 263)}, {'percentage_probability': 58.579832315444946, 'name': 'person', 'box_points': (157, 93, 554, 343)}, {'percentage_probability': 60.611504316329956, 'name': 'person', 'box_points': (1, 184, 42, 349)}, {'percentage_probability': 66.15709662437439, 'name': 'person', 'box_points': (703, 140, 725, 195)}, {'percentage_probability': 80.14811277389526, 'name': 'person', 'box_points': (626, 183, 652, 263)}, {'percentage_probability': 90.35660028457642, 'name': 'person', 'box_points': (70, 217, 140, 331)}, {'percentage_probability': 94.88868713378906, 'name': 'person', 'box_points': (698, 199, 728, 310)}, {'percentage_probability': 97.33341932296753, 'name': 'person', 'box_points': (651, 216, 689, 321)}], [{'percentage_probability': 68.05061101913452, 'name': 'bus', 'box_points': (430, 67, 535, 145)}, {'percentage_probability': 96.38801217079163, 'name': 'bus', 'box_points': (516, 96, 664, 253)}, {'percentage_probability': 98.73647093772888, 'name': 'bus', 'box_points': (180, 105, 464, 395)}, {'percentage_probability': 98.06537628173828, 'name': 'motorcycle', 'box_points': (74, 270, 130, 367)}, {'percentage_probability': 36.00325584411621, 'name': 'car', 'box_points': (79, 87, 126, 111)}, {'percentage_probability': 36.61714792251587, 'name': 'car', 'box_points': (91, 69, 129, 94)}, {'percentage_probability': 44.012290239334106, 'name': 'car', 'box_points': (500, 44, 579, 77)}, {'percentage_probability': 52.95783877372742, 'name': 'car', 'box_points': (584, 24, 647, 52)}, {'percentage_probability': 55.159515142440796, 'name': 'car', 'box_points': (45, 126, 109, 152)}, {'percentage_probability': 68.81657838821411, 'name': 'car', 'box_points': (612, 59, 688, 102)}, {'percentage_probability': 71.09447121620178, 'name': 'car', 'box_points': (439, 215, 475, 335)}, {'percentage_probability': 89.74593877792358, 'name': 'car', 'box_points': (119, 165, 197, 270)}, {'percentage_probability': 90.63202142715454, 'name': 'car', 'box_points': (729, 204, 849, 311)}, {'percentage_probability': 96.81639671325684, 'name': 'car', 'box_points': (458, 196, 504, 297)}, {'percentage_probability': 74.9581515789032, 'name': 'bicycle', 'box_points': (654, 257, 687, 332)}, {'percentage_probability': 48.782989382743835, 'name': 'person', 'box_points': (332, 198, 381, 263)}, {'percentage_probability': 50.23435950279236, 'name': 'person', 'box_points': (763, 186, 790, 213)}, {'percentage_probability': 61.5714967250824, 'name': 'person', 'box_points': (155, 95, 558, 341)}, {'percentage_probability': 62.96605467796326, 'name': 'person', 'box_points': (702, 139, 724, 194)}, {'percentage_probability': 68.072909116745, 'name': 'person', 'box_points': (4, 177, 27, 362)}, {'percentage_probability': 80.74179887771606, 'name': 'person', 'box_points': (626, 182, 652, 263)}, {'percentage_probability': 91.20214581489563, 'name': 'person', 'box_points': (66, 216, 135, 332)}, {'percentage_probability': 95.34860253334045, 'name': 'person', 'box_points': (698, 199, 728, 311)}, {'percentage_probability': 97.90418744087219, 'name': 'person', 'box_points': (651, 215, 689, 323)}], [{'percentage_probability': 70.11738419532776, 'name': 'bus', 'box_points': (432, 67, 534, 144)}, {'percentage_probability': 95.44324278831482, 'name': 'bus', 'box_points': (517, 96, 664, 253)}, {'percentage_probability': 98.74672293663025, 'name': 'bus', 'box_points': (180, 103, 464, 396)}, {'percentage_probability': 97.97809720039368, 'name': 'motorcycle', 'box_points': (74, 270, 130, 367)}, {'percentage_probability': 30.71978986263275, 'name': 'car', 'box_points': (39, 118, 105, 140)}, {'percentage_probability': 34.6377968788147, 'name': 'car', 'box_points': (79, 87, 126, 111)}, {'percentage_probability': 38.57051730155945, 'name': 'car', 'box_points': (92, 69, 129, 94)}, {'percentage_probability': 39.59181010723114, 'name': 'car', 'box_points': (500, 44, 579, 78)}, {'percentage_probability': 49.814993143081665, 'name': 'car', 'box_points': (45, 127, 108, 153)}, {'percentage_probability': 52.794164419174194, 'name': 'car', 'box_points': (584, 24, 647, 52)}, {'percentage_probability': 69.88259553909302, 'name': 'car', 'box_points': (439, 214, 476, 335)}, {'percentage_probability': 73.25511574745178, 'name': 'car', 'box_points': (612, 58, 688, 101)}, {'percentage_probability': 88.47129940986633, 'name': 'car', 'box_points': (119, 165, 197, 270)}, {'percentage_probability': 90.05041718482971, 'name': 'car', 'box_points': (730, 204, 849, 311)}, {'percentage_probability': 96.96953296661377, 'name': 'car', 'box_points': (458, 195, 504, 297)}, {'percentage_probability': 76.76354050636292, 'name': 'bicycle', 'box_points': (654, 257, 687, 332)}, {'percentage_probability': 43.02992522716522, 'name': 'person', 'box_points': (332, 198, 380, 263)}, {'percentage_probability': 50.77027082443237, 'name': 'person', 'box_points': (763, 186, 790, 213)}, {'percentage_probability': 57.814133167266846, 'name': 'person', 'box_points': (703, 139, 725, 194)}, {'percentage_probability': 61.143964529037476, 'name': 'person', 'box_points': (155, 95, 557, 341)}, {'percentage_probability': 70.31618356704712, 'name': 'person', 'box_points': (4, 176, 27, 363)}, {'percentage_probability': 81.10812902450562, 'name': 'person', 'box_points': (626, 182, 652, 263)}, {'percentage_probability': 91.37022495269775, 'name': 'person', 'box_points': (66, 216, 135, 332)}, {'percentage_probability': 95.01036405563354, 'name': 'person', 'box_points': (697, 200, 729, 310)}, {'percentage_probability': 98.08700680732727, 'name': 'person', 'box_points': (651, 215, 689, 322)}], [{'percentage_probability': 74.11633729934692, 'name': 'bus', 'box_points': (433, 65, 534, 147)}, {'percentage_probability': 95.12295126914978, 'name': 'bus', 'box_points': (515, 94, 666, 252)}, {'percentage_probability': 98.85250926017761, 'name': 'bus', 'box_points': (174, 74, 464, 376)}, {'percentage_probability': 98.22028279304504, 'name': 'motorcycle', 'box_points': (70, 270, 126, 367)}, {'percentage_probability': 31.03218674659729, 'name': 'car', 'box_points': (38, 118, 107, 140)}, {'percentage_probability': 31.777384877204895, 'name': 'car', 'box_points': (714, 203, 765, 300)}, {'percentage_probability': 36.70623302459717, 'name': 'car', 'box_points': (92, 106, 136, 131)}, {'percentage_probability': 36.94693148136139, 'name': 'car', 'box_points': (79, 87, 126, 111)}, {'percentage_probability': 37.21882700920105, 'name': 'car', 'box_points': (499, 44, 580, 78)}, {'percentage_probability': 39.05910551548004, 'name': 'car', 'box_points': (92, 69, 129, 93)}, {'percentage_probability': 48.855990171432495, 'name': 'car', 'box_points': (583, 24, 648, 51)}, {'percentage_probability': 56.54275417327881, 'name': 'car', 'box_points': (41, 121, 115, 155)}, {'percentage_probability': 69.0073013305664, 'name': 'car', 'box_points': (440, 215, 476, 336)}, {'percentage_probability': 74.28238987922668, 'name': 'car', 'box_points': (612, 59, 689, 102)}, {'percentage_probability': 87.44931221008301, 'name': 'car', 'box_points': (732, 204, 849, 312)}, {'percentage_probability': 90.76349139213562, 'name': 'car', 'box_points': (117, 164, 194, 271)}, {'percentage_probability': 96.68545126914978, 'name': 'car', 'box_points': (458, 195, 504, 298)}, {'percentage_probability': 75.52918791770935, 'name': 'bicycle', 'box_points': (654, 256, 687, 331)}, {'percentage_probability': 30.92474937438965, 'name': 'person', 'box_points': (704, 141, 725, 192)}, {'percentage_probability': 45.204395055770874, 'name': 'person', 'box_points': (763, 186, 790, 213)}, {'percentage_probability': 46.264463663101196, 'name': 'person', 'box_points': (332, 197, 380, 262)}, {'percentage_probability': 57.609957456588745, 'name': 'person', 'box_points': (163, 93, 545, 344)}, {'percentage_probability': 73.93252849578857, 'name': 'person', 'box_points': (630, 182, 657, 263)}, {'percentage_probability': 74.47311878204346, 'name': 'person', 'box_points': (2, 180, 26, 360)}, {'percentage_probability': 86.1883819103241, 'name': 'person', 'box_points': (63, 214, 134, 333)}, {'percentage_probability': 94.29273009300232, 'name': 'person', 'box_points': (698, 201, 729, 308)}, {'percentage_probability': 97.52603769302368, 'name': 'person', 'box_points': (652, 217, 689, 323)}], [{'percentage_probability': 75.91374516487122, 'name': 'bus', 'box_points': (436, 80, 531, 163)}, {'percentage_probability': 93.53793263435364, 'name': 'bus', 'box_points': (512, 95, 666, 253)}, {'percentage_probability': 99.22207593917847, 'name': 'bus', 'box_points': (180, 97, 462, 401)}, {'percentage_probability': 96.11853957176208, 'name': 'motorcycle', 'box_points': (68, 273, 122, 368)}, {'percentage_probability': 32.87504315376282, 'name': 'car', 'box_points': (500, 42, 579, 78)}, {'percentage_probability': 37.768033146858215, 'name': 'car', 'box_points': (93, 107, 136, 132)}, {'percentage_probability': 37.91641891002655, 'name': 'car', 'box_points': (79, 87, 125, 111)}, {'percentage_probability': 49.423155188560486, 'name': 'car', 'box_points': (80, 69, 124, 95)}, {'percentage_probability': 51.23528242111206, 'name': 'car', 'box_points': (584, 24, 646, 52)}, {'percentage_probability': 64.1845166683197, 'name': 'car', 'box_points': (42, 122, 115, 155)}, {'percentage_probability': 67.84663200378418, 'name': 'car', 'box_points': (440, 216, 476, 335)}, {'percentage_probability': 73.1774389743805, 'name': 'car', 'box_points': (612, 58, 689, 103)}, {'percentage_probability': 86.24066114425659, 'name': 'car', 'box_points': (730, 203, 848, 311)}, {'percentage_probability': 89.53607678413391, 'name': 'car', 'box_points': (115, 162, 194, 271)}, {'percentage_probability': 97.15386629104614, 'name': 'car', 'box_points': (455, 197, 504, 296)}, {'percentage_probability': 70.5506443977356, 'name': 'bicycle', 'box_points': (654, 257, 686, 331)}, {'percentage_probability': 36.93922162055969, 'name': 'person', 'box_points': (214, 194, 284, 259)}, {'percentage_probability': 45.95893919467926, 'name': 'person', 'box_points': (763, 187, 790, 213)}, {'percentage_probability': 47.198110818862915, 'name': 'person', 'box_points': (332, 197, 380, 264)}, {'percentage_probability': 51.11573338508606, 'name': 'person', 'box_points': (162, 93, 547, 346)}, {'percentage_probability': 72.3574697971344, 'name': 'person', 'box_points': (629, 182, 658, 264)}, {'percentage_probability': 77.81187891960144, 'name': 'person', 'box_points': (1, 178, 25, 363)}, {'percentage_probability': 85.70516109466553, 'name': 'person', 'box_points': (57, 212, 130, 336)}, {'percentage_probability': 93.83782744407654, 'name': 'person', 'box_points': (698, 201, 730, 307)}, {'percentage_probability': 96.94320559501648, 'name': 'person', 'box_points': (651, 218, 689, 322)}], [{'percentage_probability': 80.47258257865906, 'name': 'bus', 'box_points': (437, 81, 531, 163)}, {'percentage_probability': 94.3458616733551, 'name': 'bus', 'box_points': (512, 93, 667, 253)}, {'percentage_probability': 99.57154393196106, 'name': 'bus', 'box_points': (179, 96, 460, 402)}, {'percentage_probability': 95.41136622428894, 'name': 'motorcycle', 'box_points': (62, 274, 118, 370)}, {'percentage_probability': 34.75302457809448, 'name': 'car', 'box_points': (93, 107, 136, 131)}, {'percentage_probability': 35.74649393558502, 'name': 'car', 'box_points': (90, 91, 133, 116)}, {'percentage_probability': 45.191097259521484, 'name': 'car', 'box_points': (81, 69, 123, 94)}, {'percentage_probability': 50.77958106994629, 'name': 'car', 'box_points': (583, 24, 647, 52)}, {'percentage_probability': 63.83479833602905, 'name': 'car', 'box_points': (42, 122, 117, 155)}, {'percentage_probability': 67.97186732292175, 'name': 'car', 'box_points': (440, 239, 474, 342)}, {'percentage_probability': 71.36470675468445, 'name': 'car', 'box_points': (612, 59, 689, 103)}, {'percentage_probability': 83.47498774528503, 'name': 'car', 'box_points': (729, 203, 848, 311)}, {'percentage_probability': 90.67814946174622, 'name': 'car', 'box_points': (113, 161, 192, 275)}, {'percentage_probability': 96.84537649154663, 'name': 'car', 'box_points': (455, 196, 504, 296)}, {'percentage_probability': 77.3817241191864, 'name': 'bicycle', 'box_points': (654, 257, 686, 331)}, {'percentage_probability': 40.62097370624542, 'name': 'person', 'box_points': (333, 197, 381, 264)}, {'percentage_probability': 47.205379605293274, 'name': 'person', 'box_points': (157, 93, 555, 344)}, {'percentage_probability': 49.24943745136261, 'name': 'person', 'box_points': (764, 188, 790, 213)}, {'percentage_probability': 61.617422103881836, 'name': 'person', 'box_points': (213, 196, 284, 258)}, {'percentage_probability': 68.63674521446228, 'name': 'person', 'box_points': (59, 219, 120, 330)}, {'percentage_probability': 69.88849639892578, 'name': 'person', 'box_points': (1, 173, 23, 370)}, {'percentage_probability': 77.58620381355286, 'name': 'person', 'box_points': (629, 182, 657, 264)}, {'percentage_probability': 91.41563773155212, 'name': 'person', 'box_points': (699, 201, 730, 306)}, {'percentage_probability': 97.25149273872375, 'name': 'person', 'box_points': (652, 218, 690, 322)}], [{'percentage_probability': 30.176937580108643, 'name': 'truck', 'box_points': (729, 203, 848, 311)}, {'percentage_probability': 77.2971510887146, 'name': 'bus', 'box_points': (437, 81, 531, 163)}, {'percentage_probability': 95.36646604537964, 'name': 'bus', 'box_points': (510, 91, 668, 254)}, {'percentage_probability': 99.70528483390808, 'name': 'bus', 'box_points': (174, 92, 459, 406)}, {'percentage_probability': 86.504465341568, 'name': 'motorcycle', 'box_points': (61, 273, 115, 368)}, {'percentage_probability': 31.03269636631012, 'name': 'car', 'box_points': (675, 120, 751, 159)}, {'percentage_probability': 31.538784503936768, 'name': 'car', 'box_points': (90, 92, 133, 117)}, {'percentage_probability': 33.123329281806946, 'name': 'car', 'box_points': (93, 107, 135, 132)}, {'percentage_probability': 37.82408535480499, 'name': 'car', 'box_points': (38, 117, 107, 139)}, {'percentage_probability': 39.30836021900177, 'name': 'car', 'box_points': (501, 41, 578, 77)}, {'percentage_probability': 46.25307619571686, 'name': 'car', 'box_points': (80, 68, 125, 94)}, {'percentage_probability': 59.19402241706848, 'name': 'car', 'box_points': (584, 24, 647, 53)}, {'percentage_probability': 63.76054286956787, 'name': 'car', 'box_points': (43, 121, 117, 154)}, {'percentage_probability': 71.8687653541565, 'name': 'car', 'box_points': (439, 217, 477, 336)}, {'percentage_probability': 77.40949988365173, 'name': 'car', 'box_points': (613, 59, 688, 103)}, {'percentage_probability': 82.17895030975342, 'name': 'car', 'box_points': (729, 203, 848, 311)}, {'percentage_probability': 90.57655930519104, 'name': 'car', 'box_points': (110, 163, 190, 279)}, {'percentage_probability': 97.31510877609253, 'name': 'car', 'box_points': (454, 196, 504, 295)}, {'percentage_probability': 74.8788058757782, 'name': 'bicycle', 'box_points': (654, 257, 686, 332)}, {'percentage_probability': 39.83920216560364, 'name': 'person', 'box_points': (158, 93, 555, 342)}, {'percentage_probability': 39.84933793544769, 'name': 'person', 'box_points': (332, 197, 378, 263)}, {'percentage_probability': 48.862940073013306, 'name': 'person', 'box_points': (1, 173, 19, 369)}, {'percentage_probability': 53.88364791870117, 'name': 'person', 'box_points': (763, 188, 790, 213)}, {'percentage_probability': 61.166560649871826, 'name': 'person', 'box_points': (211, 194, 284, 258)}, {'percentage_probability': 76.02472305297852, 'name': 'person', 'box_points': (52, 221, 109, 325)}, {'percentage_probability': 79.33637499809265, 'name': 'person', 'box_points': (630, 181, 657, 264)}, {'percentage_probability': 92.59840250015259, 'name': 'person', 'box_points': (698, 202, 731, 305)}, {'percentage_probability': 96.86847925186157, 'name': 'person', 'box_points': (651, 217, 689, 322)}], [{'percentage_probability': 31.194207072257996, 'name': 'truck', 'box_points': (729, 202, 848, 311)}, {'percentage_probability': 75.82864165306091, 'name': 'bus', 'box_points': (437, 80, 530, 164)}, {'percentage_probability': 94.77077722549438, 'name': 'bus', 'box_points': (509, 92, 667, 254)}, {'percentage_probability': 99.77759718894958, 'name': 'bus', 'box_points': (174, 88, 458, 410)}, {'percentage_probability': 93.18498969078064, 'name': 'motorcycle', 'box_points': (54, 284, 109, 376)}, {'percentage_probability': 31.501218676567078, 'name': 'car', 'box_points': (675, 120, 751, 159)}, {'percentage_probability': 33.20036232471466, 'name': 'car', 'box_points': (500, 42, 578, 77)}, {'percentage_probability': 34.35274958610535, 'name': 'car', 'box_points': (79, 86, 126, 111)}, {'percentage_probability': 35.14220714569092, 'name': 'car', 'box_points': (95, 106, 135, 131)}, {'percentage_probability': 40.292367339134216, 'name': 'car', 'box_points': (38, 117, 109, 138)}, {'percentage_probability': 40.72276055812836, 'name': 'car', 'box_points': (89, 92, 133, 117)}, {'percentage_probability': 48.21110963821411, 'name': 'car', 'box_points': (583, 24, 647, 53)}, {'percentage_probability': 60.50633788108826, 'name': 'car', 'box_points': (78, 68, 126, 95)}, {'percentage_probability': 64.61216807365417, 'name': 'car', 'box_points': (43, 121, 118, 154)}, {'percentage_probability': 65.32381772994995, 'name': 'car', 'box_points': (438, 216, 477, 336)}, {'percentage_probability': 77.52594351768494, 'name': 'car', 'box_points': (613, 59, 689, 104)}, {'percentage_probability': 81.90084099769592, 'name': 'car', 'box_points': (729, 202, 848, 311)}, {'percentage_probability': 86.15121245384216, 'name': 'car', 'box_points': (109, 163, 188, 280)}, {'percentage_probability': 97.43272066116333, 'name': 'car', 'box_points': (454, 197, 503, 295)}, {'percentage_probability': 70.87395191192627, 'name': 'bicycle', 'box_points': (654, 257, 686, 332)}, {'percentage_probability': 32.16234743595123, 'name': 'person', 'box_points': (704, 141, 726, 192)}, {'percentage_probability': 35.951995849609375, 'name': 'person', 'box_points': (160, 93, 554, 344)}, {'percentage_probability': 39.63005840778351, 'name': 'person', 'box_points': (0, 171, 16, 370)}, {'percentage_probability': 42.478546500205994, 'name': 'person', 'box_points': (667, 166, 686, 218)}, {'percentage_probability': 49.34081733226776, 'name': 'person', 'box_points': (332, 197, 379, 264)}, {'percentage_probability': 55.183106660842896, 'name': 'person', 'box_points': (762, 187, 790, 213)}, {'percentage_probability': 67.48546957969666, 'name': 'person', 'box_points': (211, 194, 285, 258)}, {'percentage_probability': 77.78768539428711, 'name': 'person', 'box_points': (630, 181, 657, 264)}, {'percentage_probability': 87.07519173622131, 'name': 'person', 'box_points': (43, 239, 117, 359)}, {'percentage_probability': 93.96042823791504, 'name': 'person', 'box_points': (698, 200, 731, 305)}, {'percentage_probability': 97.74518609046936, 'name': 'person', 'box_points': (651, 214, 689, 324)}], [{'percentage_probability': 31.54093027114868, 'name': 'truck', 'box_points': (729, 202, 848, 311)}, {'percentage_probability': 76.29989385604858, 'name': 'bus', 'box_points': (437, 80, 530, 164)}, {'percentage_probability': 94.70686912536621, 'name': 'bus', 'box_points': (509, 92, 667, 254)}, {'percentage_probability': 99.77763891220093, 'name': 'bus', 'box_points': (174, 88, 457, 410)}, {'percentage_probability': 93.18041205406189, 'name': 'motorcycle', 'box_points': (54, 284, 109, 376)}, {'percentage_probability': 32.066091895103455, 'name': 'car', 'box_points': (675, 120, 751, 160)}, {'percentage_probability': 33.482226729393005, 'name': 'car', 'box_points': (501, 42, 578, 77)}, {'percentage_probability': 33.66421163082123, 'name': 'car', 'box_points': (79, 86, 126, 111)}, {'percentage_probability': 35.35621464252472, 'name': 'car', 'box_points': (94, 106, 135, 131)}, {'percentage_probability': 40.18446207046509, 'name': 'car', 'box_points': (38, 117, 109, 138)}, {'percentage_probability': 41.24627709388733, 'name': 'car', 'box_points': (89, 92, 134, 118)}, {'percentage_probability': 48.56540858745575, 'name': 'car', 'box_points': (583, 24, 647, 53)}, {'percentage_probability': 60.194772481918335, 'name': 'car', 'box_points': (78, 68, 127, 95)}, {'percentage_probability': 65.11224508285522, 'name': 'car', 'box_points': (43, 121, 118, 154)}, {'percentage_probability': 65.24097323417664, 'name': 'car', 'box_points': (438, 216, 477, 336)}, {'percentage_probability': 77.53556966781616, 'name': 'car', 'box_points': (613, 59, 689, 104)}, {'percentage_probability': 81.75934553146362, 'name': 'car', 'box_points': (729, 202, 848, 311)}, {'percentage_probability': 85.92413663864136, 'name': 'car', 'box_points': (109, 163, 188, 279)}, {'percentage_probability': 97.39541411399841, 'name': 'car', 'box_points': (454, 197, 503, 295)}, {'percentage_probability': 70.71692943572998, 'name': 'bicycle', 'box_points': (654, 257, 686, 332)}, {'percentage_probability': 32.374680042266846, 'name': 'person', 'box_points': (704, 141, 726, 192)}, {'percentage_probability': 35.88072061538696, 'name': 'person', 'box_points': (160, 93, 554, 344)}, {'percentage_probability': 38.96181285381317, 'name': 'person', 'box_points': (0, 171, 16, 370)}, {'percentage_probability': 42.45581924915314, 'name': 'person', 'box_points': (667, 166, 686, 218)}, {'percentage_probability': 48.77220392227173, 'name': 'person', 'box_points': (332, 196, 380, 264)}, {'percentage_probability': 55.00238537788391, 'name': 'person', 'box_points': (762, 187, 790, 213)}, {'percentage_probability': 63.61921429634094, 'name': 'person', 'box_points': (211, 194, 285, 258)}, {'percentage_probability': 77.77476906776428, 'name': 'person', 'box_points': (630, 181, 657, 264)}, {'percentage_probability': 86.80411577224731, 'name': 'person', 'box_points': (43, 239, 117, 359)}, {'percentage_probability': 93.69082450866699, 'name': 'person', 'box_points': (698, 200, 731, 305)}, {'percentage_probability': 97.75940179824829, 'name': 'person', 'box_points': (651, 214, 689, 324)}], [{'percentage_probability': 34.38720405101776, 'name': 'truck', 'box_points': (728, 202, 848, 312)}, {'percentage_probability': 76.57642960548401, 'name': 'bus', 'box_points': (436, 81, 530, 164)}, {'percentage_probability': 96.30280137062073, 'name': 'bus', 'box_points': (507, 92, 664, 254)}, {'percentage_probability': 99.80274438858032, 'name': 'bus', 'box_points': (174, 87, 457, 412)}, {'percentage_probability': 96.50717973709106, 'name': 'motorcycle', 'box_points': (51, 283, 106, 378)}, {'percentage_probability': 33.17254185676575, 'name': 'car', 'box_points': (492, 44, 556, 69)}, {'percentage_probability': 38.40756714344025, 'name': 'car', 'box_points': (517, 46, 572, 71)}, {'percentage_probability': 41.05578064918518, 'name': 'car', 'box_points': (95, 106, 135, 132)}, {'percentage_probability': 44.06380653381348, 'name': 'car', 'box_points': (39, 117, 109, 138)}, {'percentage_probability': 44.77411508560181, 'name': 'car', 'box_points': (88, 91, 135, 118)}, {'percentage_probability': 59.66396927833557, 'name': 'car', 'box_points': (584, 24, 647, 52)}, {'percentage_probability': 62.71898150444031, 'name': 'car', 'box_points': (44, 121, 118, 154)}, {'percentage_probability': 64.40765261650085, 'name': 'car', 'box_points': (77, 69, 127, 96)}, {'percentage_probability': 67.61466264724731, 'name': 'car', 'box_points': (439, 216, 477, 337)}, {'percentage_probability': 78.21256518363953, 'name': 'car', 'box_points': (613, 59, 688, 104)}, {'percentage_probability': 80.2405297756195, 'name': 'car', 'box_points': (728, 202, 848, 312)}, {'percentage_probability': 83.86163711547852, 'name': 'car', 'box_points': (106, 164, 188, 280)}, {'percentage_probability': 97.36934900283813, 'name': 'car', 'box_points': (454, 197, 503, 295)}, {'percentage_probability': 67.37295985221863, 'name': 'bicycle', 'box_points': (654, 257, 685, 332)}, {'percentage_probability': 31.993678212165833, 'name': 'person', 'box_points': (704, 141, 725, 190)}, {'percentage_probability': 32.37456679344177, 'name': 'person', 'box_points': (163, 90, 551, 344)}, {'percentage_probability': 33.37143659591675, 'name': 'person', 'box_points': (726, 142, 747, 192)}, {'percentage_probability': 44.79348063468933, 'name': 'person', 'box_points': (333, 196, 380, 264)}, {'percentage_probability': 51.19306445121765, 'name': 'person', 'box_points': (665, 166, 686, 219)}, {'percentage_probability': 60.01795530319214, 'name': 'person', 'box_points': (760, 179, 791, 209)}, {'percentage_probability': 63.292402029037476, 'name': 'person', 'box_points': (211, 195, 283, 258)}, {'percentage_probability': 77.78417468070984, 'name': 'person', 'box_points': (629, 182, 657, 265)}, {'percentage_probability': 92.9023027420044, 'name': 'person', 'box_points': (38, 237, 116, 357)}, {'percentage_probability': 94.48010921478271, 'name': 'person', 'box_points': (699, 199, 732, 307)}, {'percentage_probability': 97.89757132530212, 'name': 'person', 'box_points': (652, 212, 689, 325)}], [{'percentage_probability': 31.749901175498962, 'name': 'truck', 'box_points': (726, 201, 848, 311)}, {'percentage_probability': 73.91170263290405, 'name': 'bus', 'box_points': (437, 80, 530, 163)}, {'percentage_probability': 95.35778760910034, 'name': 'bus', 'box_points': (507, 94, 659, 254)}, {'percentage_probability': 99.69611167907715, 'name': 'bus', 'box_points': (173, 88, 456, 410)}, {'percentage_probability': 30.21189272403717, 'name': 'motorcycle', 'box_points': (654, 257, 685, 332)}, {'percentage_probability': 95.55157423019409, 'name': 'motorcycle', 'box_points': (48, 283, 103, 380)}, {'percentage_probability': 30.504503846168518, 'name': 'car', 'box_points': (94, 105, 135, 130)}, {'percentage_probability': 32.57994055747986, 'name': 'car', 'box_points': (492, 44, 555, 69)}, {'percentage_probability': 36.36416792869568, 'name': 'car', 'box_points': (37, 117, 109, 138)}, {'percentage_probability': 36.39397621154785, 'name': 'car', 'box_points': (681, 51, 759, 113)}, {'percentage_probability': 43.84659230709076, 'name': 'car', 'box_points': (517, 45, 573, 72)}, {'percentage_probability': 46.74572050571442, 'name': 'car', 'box_points': (88, 90, 136, 117)}, {'percentage_probability': 59.96849536895752, 'name': 'car', 'box_points': (77, 69, 128, 96)}, {'percentage_probability': 60.919082164764404, 'name': 'car', 'box_points': (585, 24, 646, 53)}, {'percentage_probability': 67.20002293586731, 'name': 'car', 'box_points': (44, 122, 119, 154)}, {'percentage_probability': 69.73931193351746, 'name': 'car', 'box_points': (438, 233, 473, 348)}, {'percentage_probability': 82.32583403587341, 'name': 'car', 'box_points': (613, 59, 688, 104)}, {'percentage_probability': 82.56447911262512, 'name': 'car', 'box_points': (726, 201, 848, 311)}, {'percentage_probability': 86.56780123710632, 'name': 'car', 'box_points': (106, 165, 187, 281)}, {'percentage_probability': 97.62600064277649, 'name': 'car', 'box_points': (453, 197, 503, 295)}, {'percentage_probability': 73.30902814865112, 'name': 'bicycle', 'box_points': (654, 257, 685, 332)}, {'percentage_probability': 30.93571364879608, 'name': 'person', 'box_points': (727, 142, 747, 194)}, {'percentage_probability': 31.431162357330322, 'name': 'person', 'box_points': (704, 140, 725, 191)}, {'percentage_probability': 31.55968487262726, 'name': 'person', 'box_points': (157, 89, 558, 341)}, {'percentage_probability': 50.95236301422119, 'name': 'person', 'box_points': (332, 195, 380, 266)}, {'percentage_probability': 60.5324387550354, 'name': 'person', 'box_points': (666, 166, 684, 220)}, {'percentage_probability': 61.85857057571411, 'name': 'person', 'box_points': (760, 179, 791, 209)}, {'percentage_probability': 68.77299547195435, 'name': 'person', 'box_points': (209, 197, 282, 259)}, {'percentage_probability': 82.01414346694946, 'name': 'person', 'box_points': (630, 182, 657, 265)}, {'percentage_probability': 93.05714964866638, 'name': 'person', 'box_points': (34, 237, 112, 358)}, {'percentage_probability': 94.26581263542175, 'name': 'person', 'box_points': (699, 199, 733, 309)}, {'percentage_probability': 98.35252165794373, 'name': 'person', 'box_points': (652, 211, 689, 325)}], [{'percentage_probability': 78.96385788917542, 'name': 'bus', 'box_points': (437, 80, 529, 162)}, {'percentage_probability': 96.29350304603577, 'name': 'bus', 'box_points': (505, 92, 659, 255)}, {'percentage_probability': 99.634450674057, 'name': 'bus', 'box_points': (171, 89, 457, 409)}, {'percentage_probability': 50.21001696586609, 'name': 'motorcycle', 'box_points': (654, 257, 686, 332)}, {'percentage_probability': 95.6187903881073, 'name': 'motorcycle', 'box_points': (43, 282, 102, 381)}, {'percentage_probability': 30.432242155075073, 'name': 'car', 'box_points': (95, 106, 135, 131)}, {'percentage_probability': 32.769882678985596, 'name': 'car', 'box_points': (682, 52, 758, 111)}, {'percentage_probability': 36.746519804000854, 'name': 'car', 'box_points': (493, 44, 554, 69)}, {'percentage_probability': 38.627979159355164, 'name': 'car', 'box_points': (37, 117, 109, 138)}, {'percentage_probability': 42.96354651451111, 'name': 'car', 'box_points': (518, 46, 572, 73)}, {'percentage_probability': 46.57238721847534, 'name': 'car', 'box_points': (88, 91, 137, 117)}, {'percentage_probability': 60.646605491638184, 'name': 'car', 'box_points': (77, 69, 127, 96)}, {'percentage_probability': 62.44799494743347, 'name': 'car', 'box_points': (585, 25, 646, 53)}, {'percentage_probability': 70.09032964706421, 'name': 'car', 'box_points': (44, 121, 118, 153)}, {'percentage_probability': 70.27367353439331, 'name': 'car', 'box_points': (437, 234, 472, 348)}, {'percentage_probability': 80.47775030136108, 'name': 'car', 'box_points': (613, 59, 688, 103)}, {'percentage_probability': 83.95156860351562, 'name': 'car', 'box_points': (728, 202, 848, 311)}, {'percentage_probability': 89.51553702354431, 'name': 'car', 'box_points': (105, 163, 187, 281)}, {'percentage_probability': 97.44793176651001, 'name': 'car', 'box_points': (452, 197, 502, 296)}, {'percentage_probability': 61.038076877593994, 'name': 'bicycle', 'box_points': (654, 257, 686, 332)}, {'percentage_probability': 46.86194956302643, 'name': 'person', 'box_points': (331, 196, 380, 266)}, {'percentage_probability': 54.49521541595459, 'name': 'person', 'box_points': (207, 196, 281, 259)}, {'percentage_probability': 60.76473593711853, 'name': 'person', 'box_points': (665, 166, 684, 220)}, {'percentage_probability': 68.11357140541077, 'name': 'person', 'box_points': (760, 178, 790, 210)}, {'percentage_probability': 79.28592562675476, 'name': 'person', 'box_points': (629, 183, 657, 264)}, {'percentage_probability': 87.89259791374207, 'name': 'person', 'box_points': (30, 239, 109, 360)}, {'percentage_probability': 93.30500960350037, 'name': 'person', 'box_points': (700, 198, 734, 309)}, {'percentage_probability': 98.31166863441467, 'name': 'person', 'box_points': (652, 212, 690, 324)}], [{'percentage_probability': 82.2407603263855, 'name': 'bus', 'box_points': (437, 78, 529, 163)}, {'percentage_probability': 97.41659760475159, 'name': 'bus', 'box_points': (504, 92, 660, 255)}, {'percentage_probability': 99.19785857200623, 'name': 'bus', 'box_points': (163, 73, 458, 381)}, {'percentage_probability': 44.28519010543823, 'name': 'motorcycle', 'box_points': (654, 257, 686, 333)}, {'percentage_probability': 94.28367614746094, 'name': 'motorcycle', 'box_points': (38, 284, 98, 383)}, {'percentage_probability': 31.58174157142639, 'name': 'car', 'box_points': (682, 52, 758, 111)}, {'percentage_probability': 33.2750529050827, 'name': 'car', 'box_points': (37, 117, 109, 138)}, {'percentage_probability': 35.31275987625122, 'name': 'car', 'box_points': (491, 44, 553, 69)}, {'percentage_probability': 43.119439482688904, 'name': 'car', 'box_points': (519, 46, 573, 72)}, {'percentage_probability': 52.15545892715454, 'name': 'car', 'box_points': (88, 90, 137, 117)}, {'percentage_probability': 59.87662076950073, 'name': 'car', 'box_points': (585, 24, 646, 53)}, {'percentage_probability': 61.01861596107483, 'name': 'car', 'box_points': (78, 68, 125, 96)}, {'percentage_probability': 68.62263083457947, 'name': 'car', 'box_points': (437, 233, 471, 350)}, {'percentage_probability': 74.11953210830688, 'name': 'car', 'box_points': (43, 121, 120, 153)}, {'percentage_probability': 80.04424571990967, 'name': 'car', 'box_points': (613, 59, 688, 104)}, {'percentage_probability': 86.74343824386597, 'name': 'car', 'box_points': (732, 202, 850, 312)}, {'percentage_probability': 93.41477155685425, 'name': 'car', 'box_points': (104, 162, 187, 280)}, {'percentage_probability': 97.73800373077393, 'name': 'car', 'box_points': (451, 196, 501, 296)}, {'percentage_probability': 67.39141941070557, 'name': 'bicycle', 'box_points': (654, 257, 686, 333)}, {'percentage_probability': 37.63577938079834, 'name': 'person', 'box_points': (208, 194, 281, 259)}, {'percentage_probability': 41.56236946582794, 'name': 'person', 'box_points': (328, 197, 376, 267)}, {'percentage_probability': 57.650208473205566, 'name': 'person', 'box_points': (665, 165, 683, 222)}, {'percentage_probability': 65.06280303001404, 'name': 'person', 'box_points': (760, 177, 790, 210)}, {'percentage_probability': 82.567697763443, 'name': 'person', 'box_points': (629, 182, 657, 264)}, {'percentage_probability': 87.4291718006134, 'name': 'person', 'box_points': (25, 235, 106, 361)}, {'percentage_probability': 94.2313551902771, 'name': 'person', 'box_points': (702, 198, 736, 310)}, {'percentage_probability': 98.86744618415833, 'name': 'person', 'box_points': (653, 211, 690, 326)}], [{'percentage_probability': 85.23881435394287, 'name': 'bus', 'box_points': (437, 79, 529, 162)}, {'percentage_probability': 98.24867844581604, 'name': 'bus', 'box_points': (502, 90, 660, 255)}, {'percentage_probability': 99.41819906234741, 'name': 'bus', 'box_points': (168, 96, 458, 405)}, {'percentage_probability': 64.16072249412537, 'name': 'motorcycle', 'box_points': (654, 256, 687, 333)}, {'percentage_probability': 94.37679052352905, 'name': 'motorcycle', 'box_points': (33, 287, 91, 384)}, {'percentage_probability': 32.10407197475433, 'name': 'car', 'box_points': (708, 202, 756, 304)}, {'percentage_probability': 33.79647731781006, 'name': 'car', 'box_points': (492, 44, 554, 70)}, {'percentage_probability': 35.48703193664551, 'name': 'car', 'box_points': (36, 116, 108, 138)}, {'percentage_probability': 45.55663466453552, 'name': 'car', 'box_points': (517, 47, 573, 74)}, {'percentage_probability': 47.29326367378235, 'name': 'car', 'box_points': (88, 91, 136, 118)}, {'percentage_probability': 56.64830207824707, 'name': 'car', 'box_points': (585, 24, 646, 54)}, {'percentage_probability': 62.08910346031189, 'name': 'car', 'box_points': (437, 232, 470, 350)}, {'percentage_probability': 68.59003901481628, 'name': 'car', 'box_points': (42, 121, 120, 153)}, {'percentage_probability': 68.7457799911499, 'name': 'car', 'box_points': (75, 68, 127, 96)}, {'percentage_probability': 74.76482391357422, 'name': 'car', 'box_points': (612, 59, 688, 104)}, {'percentage_probability': 86.08265519142151, 'name': 'car', 'box_points': (733, 202, 850, 312)}, {'percentage_probability': 93.33373308181763, 'name': 'car', 'box_points': (104, 164, 187, 281)}, {'percentage_probability': 97.67029881477356, 'name': 'car', 'box_points': (452, 196, 500, 297)}, {'percentage_probability': 41.96500480175018, 'name': 'bicycle', 'box_points': (654, 256, 687, 333)}, {'percentage_probability': 34.00747776031494, 'name': 'person', 'box_points': (327, 199, 375, 268)}, {'percentage_probability': 40.01411199569702, 'name': 'person', 'box_points': (206, 194, 280, 259)}, {'percentage_probability': 52.01454162597656, 'name': 'person', 'box_points': (664, 165, 683, 221)}, {'percentage_probability': 54.212892055511475, 'name': 'person', 'box_points': (761, 178, 790, 210)}, {'percentage_probability': 83.37919116020203, 'name': 'person', 'box_points': (630, 181, 657, 265)}, {'percentage_probability': 90.22685289382935, 'name': 'person', 'box_points': (703, 200, 735, 307)}, {'percentage_probability': 91.64494276046753, 'name': 'person', 'box_points': (23, 232, 101, 361)}, {'percentage_probability': 98.50229620933533, 'name': 'person', 'box_points': (653, 212, 691, 325)}], [{'percentage_probability': 84.81463193893433, 'name': 'bus', 'box_points': (437, 79, 529, 162)}, {'percentage_probability': 98.26499819755554, 'name': 'bus', 'box_points': (502, 90, 660, 255)}, {'percentage_probability': 99.43455457687378, 'name': 'bus', 'box_points': (168, 96, 458, 405)}, {'percentage_probability': 64.05494809150696, 'name': 'motorcycle', 'box_points': (654, 256, 687, 333)}, {'percentage_probability': 94.27719116210938, 'name': 'motorcycle', 'box_points': (33, 287, 91, 384)}, {'percentage_probability': 32.12394416332245, 'name': 'car', 'box_points': (708, 202, 756, 304)}, {'percentage_probability': 33.78474712371826, 'name': 'car', 'box_points': (492, 44, 554, 70)}, {'percentage_probability': 35.77521741390228, 'name': 'car', 'box_points': (36, 116, 108, 138)}, {'percentage_probability': 45.12913227081299, 'name': 'car', 'box_points': (517, 47, 573, 74)}, {'percentage_probability': 47.179511189460754, 'name': 'car', 'box_points': (88, 91, 136, 118)}, {'percentage_probability': 56.57145977020264, 'name': 'car', 'box_points': (585, 24, 646, 54)}, {'percentage_probability': 61.723095178604126, 'name': 'car', 'box_points': (437, 233, 470, 350)}, {'percentage_probability': 68.70080232620239, 'name': 'car', 'box_points': (75, 68, 127, 96)}, {'percentage_probability': 68.93942952156067, 'name': 'car', 'box_points': (43, 121, 120, 153)}, {'percentage_probability': 75.02562403678894, 'name': 'car', 'box_points': (613, 59, 688, 104)}, {'percentage_probability': 86.06448173522949, 'name': 'car', 'box_points': (733, 202, 850, 312)}, {'percentage_probability': 93.27707886695862, 'name': 'car', 'box_points': (104, 164, 186, 281)}, {'percentage_probability': 97.67611026763916, 'name': 'car', 'box_points': (452, 196, 500, 297)}, {'percentage_probability': 41.65308475494385, 'name': 'bicycle', 'box_points': (654, 256, 687, 333)}, {'percentage_probability': 38.714706897735596, 'name': 'person', 'box_points': (205, 195, 280, 259)}, {'percentage_probability': 52.033042907714844, 'name': 'person', 'box_points': (664, 165, 683, 221)}, {'percentage_probability': 54.81060743331909, 'name': 'person', 'box_points': (761, 177, 790, 210)}, {'percentage_probability': 83.65730047225952, 'name': 'person', 'box_points': (630, 181, 657, 265)}, {'percentage_probability': 90.49687385559082, 'name': 'person', 'box_points': (703, 200, 735, 307)}, {'percentage_probability': 91.6032612323761, 'name': 'person', 'box_points': (23, 232, 101, 361)}, {'percentage_probability': 98.51881861686707, 'name': 'person', 'box_points': (653, 212, 691, 325)}], [{'percentage_probability': 84.38332676887512, 'name': 'bus', 'box_points': (437, 78, 529, 163)}, {'percentage_probability': 98.2822597026825, 'name': 'bus', 'box_points': (500, 90, 659, 256)}, {'percentage_probability': 99.67314004898071, 'name': 'bus', 'box_points': (166, 91, 460, 407)}, {'percentage_probability': 58.297938108444214, 'name': 'motorcycle', 'box_points': (654, 256, 687, 334)}, {'percentage_probability': 97.88724780082703, 'name': 'motorcycle', 'box_points': (30, 286, 88, 387)}, {'percentage_probability': 30.25447726249695, 'name': 'car', 'box_points': (492, 44, 554, 69)}, {'percentage_probability': 38.50405514240265, 'name': 'car', 'box_points': (436, 233, 469, 352)}, {'percentage_probability': 44.22197937965393, 'name': 'car', 'box_points': (517, 46, 574, 73)}, {'percentage_probability': 44.43452060222626, 'name': 'car', 'box_points': (88, 91, 136, 118)}, {'percentage_probability': 56.903159618377686, 'name': 'car', 'box_points': (585, 24, 646, 53)}, {'percentage_probability': 65.78866839408875, 'name': 'car', 'box_points': (74, 69, 127, 97)}, {'percentage_probability': 68.28009486198425, 'name': 'car', 'box_points': (43, 120, 120, 154)}, {'percentage_probability': 75.11818408966064, 'name': 'car', 'box_points': (612, 59, 688, 104)}, {'percentage_probability': 87.61110305786133, 'name': 'car', 'box_points': (732, 203, 849, 312)}, {'percentage_probability': 92.81589984893799, 'name': 'car', 'box_points': (102, 167, 181, 284)}, {'percentage_probability': 97.06457853317261, 'name': 'car', 'box_points': (453, 196, 500, 300)}, {'percentage_probability': 49.029138684272766, 'name': 'bicycle', 'box_points': (654, 256, 687, 334)}, {'percentage_probability': 30.736926198005676, 'name': 'person', 'box_points': (702, 140, 724, 191)}, {'percentage_probability': 43.387430906295776, 'name': 'person', 'box_points': (204, 197, 280, 261)}, {'percentage_probability': 51.11696720123291, 'name': 'person', 'box_points': (760, 177, 789, 210)}, {'percentage_probability': 56.286031007766724, 'name': 'person', 'box_points': (665, 165, 684, 220)}, {'percentage_probability': 80.29382228851318, 'name': 'person', 'box_points': (625, 181, 652, 268)}, {'percentage_probability': 92.3288106918335, 'name': 'person', 'box_points': (20, 232, 96, 363)}, {'percentage_probability': 94.09220218658447, 'name': 'person', 'box_points': (704, 201, 734, 309)}, {'percentage_probability': 98.503977060318, 'name': 'person', 'box_points': (653, 214, 691, 326)}], [{'percentage_probability': 82.58864879608154, 'name': 'bus', 'box_points': (437, 77, 531, 162)}, {'percentage_probability': 98.07835817337036, 'name': 'bus', 'box_points': (499, 91, 659, 257)}, {'percentage_probability': 99.70232248306274, 'name': 'bus', 'box_points': (164, 93, 459, 406)}, {'percentage_probability': 71.48898839950562, 'name': 'motorcycle', 'box_points': (655, 256, 688, 334)}, {'percentage_probability': 98.13886284828186, 'name': 'motorcycle', 'box_points': (27, 287, 85, 388)}, {'percentage_probability': 47.20166623592377, 'name': 'car', 'box_points': (89, 91, 136, 117)}, {'percentage_probability': 47.64687716960907, 'name': 'car', 'box_points': (503, 43, 577, 80)}, {'percentage_probability': 48.04050326347351, 'name': 'car', 'box_points': (436, 234, 469, 352)}, {'percentage_probability': 54.76762056350708, 'name': 'car', 'box_points': (584, 25, 647, 53)}, {'percentage_probability': 57.790595293045044, 'name': 'car', 'box_points': (75, 69, 126, 96)}, {'percentage_probability': 60.93060374259949, 'name': 'car', 'box_points': (43, 120, 121, 154)}, {'percentage_probability': 68.1499719619751, 'name': 'car', 'box_points': (613, 59, 689, 103)}, {'percentage_probability': 86.77908778190613, 'name': 'car', 'box_points': (732, 203, 850, 311)}, {'percentage_probability': 93.03487539291382, 'name': 'car', 'box_points': (99, 168, 177, 285)}, {'percentage_probability': 97.08181023597717, 'name': 'car', 'box_points': (452, 196, 500, 299)}, {'percentage_probability': 30.873659253120422, 'name': 'person', 'box_points': (324, 213, 372, 276)}, {'percentage_probability': 53.767383098602295, 'name': 'person', 'box_points': (665, 166, 684, 220)}, {'percentage_probability': 55.94940781593323, 'name': 'person', 'box_points': (761, 178, 790, 210)}, {'percentage_probability': 81.15515112876892, 'name': 'person', 'box_points': (630, 181, 657, 264)}, {'percentage_probability': 93.58222484588623, 'name': 'person', 'box_points': (18, 231, 93, 365)}, {'percentage_probability': 94.01090741157532, 'name': 'person', 'box_points': (704, 202, 736, 308)}, {'percentage_probability': 97.72757291793823, 'name': 'person', 'box_points': (654, 215, 692, 324)}]]

Array for output count for unique objects in each frame :  [{'motorcycle': 2, 'person': 8, 'bicycle': 1, 'bus': 3, 'car': 11}, {'motorcycle': 2, 'person': 9, 'bus': 3, 'car': 12}, {'motorcycle': 2, 'person': 9, 'bicycle': 1, 'bus': 3, 'car': 10}, {'motorcycle': 2, 'person': 9, 'bicycle': 1, 'bus': 3, 'car': 10}, {'motorcycle': 1, 'person': 9, 'bicycle': 1, 'bus': 3, 'car': 10}, {'motorcycle': 1, 'person': 9, 'bicycle': 1, 'bus': 3, 'car': 11}, {'motorcycle': 1, 'person': 9, 'bicycle': 1, 'bus': 3, 'car': 13}, {'motorcycle': 1, 'person': 9, 'bicycle': 1, 'bus': 3, 'car': 11}, {'motorcycle': 1, 'person': 9, 'bicycle': 1, 'bus': 3, 'car': 10}, {'truck': 1, 'bicycle': 1, 'car': 13, 'person': 9, 'bus': 3, 'motorcycle': 1}, {'truck': 1, 'bicycle': 1, 'car': 14, 'person': 11, 'bus': 3, 'motorcycle': 1}, {'truck': 1, 'bicycle': 1, 'car': 14, 'person': 11, 'bus': 3, 'motorcycle': 1}, {'truck': 1, 'bicycle': 1, 'car': 13, 'person': 11, 'bus': 3, 'motorcycle': 1}, {'truck': 1, 'bicycle': 1, 'car': 14, 'person': 11, 'bus': 3, 'motorcycle': 2}, {'motorcycle': 2, 'person': 8, 'bicycle': 1, 'bus': 3, 'car': 14}, {'motorcycle': 2, 'person': 8, 'bicycle': 1, 'bus': 3, 'car': 13}, {'motorcycle': 2, 'person': 8, 'bicycle': 1, 'bus': 3, 'car': 13}, {'motorcycle': 2, 'person': 7, 'bicycle': 1, 'bus': 3, 'car': 13}, {'motorcycle': 2, 'person': 8, 'bicycle': 1, 'bus': 3, 'car': 11}, {'motorcycle': 2, 'person': 7, 'bus': 3, 'car': 10}]

Output average count for unique objects in the last second:  {'motorcycle': 1.55, 'bicycle': 0.9, 'car': 12.0, 'person': 8.95, 'bus': 3.0, 'truck': 0.25}

------------END OF A SECOND --------------

The analytical data generated and retrieved above might look like a huge puzzle as compared to the data we retrieved for the per-frame detection. Allow me to break it down for you:

i. The first value sent into our function is the number of the last second processed for detection.

ii. The second value sent to our function is an array of sub-arrays. Each sub-array corresponds to each frame contained in the last second. Each sub-array contains dictionaries, and each dictionary corresponds to each object detected in the frame.

iii. The third value sent to our function is an array of dictionaries. Each dictionary corresponds to each frame. Each dictionary contains names and numbers of instances for each unique object detected in the frame.

iv. The fourth value sent to our function is a dictionary that contains the average number of instances of each unique object detected in all the frames contained in the last second.

With this data generated, we can visualize the entire analytics of the detection process and/or store the data in a database for retrieval later.

Now we’re going to run some code to obtain the analytical data for each second processed for detection, visualize the detected frame at the end of that second, and plot a pie chart for all the unique objects detected.

See the code below:

from imageai.Detection import VideoObjectDetection
import os
from matplotlib import pyplot as plt


execution_path = os.getcwd()

color_index = {'bus': 'red', 'handbag': 'steelblue', 'giraffe': 'orange', 'spoon': 'gray', 'cup': 'yellow', 'chair': 'green', 'elephant': 'pink', 'truck': 'indigo', 'motorcycle': 'azure', 'refrigerator': 'gold', 'keyboard': 'violet', 'cow': 'magenta', 'mouse': 'crimson', 'sports ball': 'raspberry', 'horse': 'maroon', 'cat': 'orchid', 'boat': 'slateblue', 'hot dog': 'navy', 'apple': 'cobalt', 'parking meter': 'aliceblue', 'sandwich': 'skyblue', 'skis': 'deepskyblue', 'microwave': 'peacock', 'knife': 'cadetblue', 'baseball bat': 'cyan', 'oven': 'lightcyan', 'carrot': 'coldgrey', 'scissors': 'seagreen', 'sheep': 'deepgreen', 'toothbrush': 'cobaltgreen', 'fire hydrant': 'limegreen', 'remote': 'forestgreen', 'bicycle': 'olivedrab', 'toilet': 'ivory', 'tv': 'khaki', 'skateboard': 'palegoldenrod', 'train': 'cornsilk', 'zebra': 'wheat', 'tie': 'burlywood', 'orange': 'melon', 'bird': 'bisque', 'dining table': 'chocolate', 'hair drier': 'sandybrown', 'cell phone': 'sienna', 'sink': 'coral', 'bench': 'salmon', 'bottle': 'brown', 'car': 'silver', 'bowl': 'maroon', 'tennis racket': 'palevilotered', 'airplane': 'lavenderblush', 'pizza': 'hotpink', 'umbrella': 'deeppink', 'bear': 'plum', 'fork': 'purple', 'laptop': 'indigo', 'vase': 'mediumpurple', 'baseball glove': 'slateblue', 'traffic light': 'mediumblue', 'bed': 'navy', 'broccoli': 'royalblue', 'backpack': 'slategray', 'snowboard': 'skyblue', 'kite': 'cadetblue', 'teddy bear': 'peacock', 'clock': 'lightcyan', 'wine glass': 'teal', 'frisbee': 'aquamarine', 'donut': 'mincream', 'suitcase': 'seagreen', 'dog': 'springgreen', 'banana': 'emeraldgreen', 'person': 'honeydew', 'surfboard': 'palegreen', 'cake': 'sapgreen', 'book': 'lawngreen', 'potted plant': 'greenyellow', 'toaster': 'ivory', 'stop sign': 'beige', 'couch': 'khaki'}


resized = False

def forSecond(frame_number, output_arrays, count_arrays, average_count, returned_frame):

    plt.clf()

    this_colors = []
    labels = []
    sizes = []

    counter = 0

    for eachItem in average_count:
        counter += 1
        labels.append(eachItem + " = " + str(average_count[eachItem]))
        sizes.append(average_count[eachItem])
        this_colors.append(color_index[eachItem])

    global resized

    if (resized == False):
        manager = plt.get_current_fig_manager()
        manager.resize(width=1200, height=600)
        resized = True

    plt.subplot(1, 2, 1)
    plt.title("Second : " + str(frame_number))
    plt.axis("off")
    plt.imshow(returned_frame, interpolation="none")

    plt.subplot(1, 2, 2)
    plt.title("Analysis: " + str(frame_number))
    plt.pie(sizes, labels=labels, colors=this_colors, shadow=True, startangle=140, autopct="%1.1f%%")

    plt.pause(0.01)



video_detector = VideoObjectDetection()
video_detector.setModelTypeAsYOLOv3()
video_detector.setModelPath(os.path.join(execution_path, "yolo.h5"))
video_detector.loadModel(detection_speed="fast")

plt.show()

video_detector.detectObjectsFromVideo(input_file_path=os.path.join(execution_path, "traffic-mini.mp4"), save_detected_video=False ,  frames_per_second=20, per_second_function=forSecond,  minimum_percentage_probability=30, return_detected_frame=True, log_progress=True)

Conclusion

Again, the above code might look a bit confusing, so let me break it down:

i. We imported the ImageAI detection class and the Matplotlib chart plotting class.

ii. We defined a color index for the pie chart that we’ll use to visualize the average number of instances for each unique object detected in every second of our video.

iii. We created the function that will obtain the analytical data from the detection function. Notice that the function has an extra parameter returned_frame that it expects. This parameter corresponds to the last frame of the last second of the video processed for detection.

iv. We created all the label, color, and size properties for each pie chart and updated these properties with the obtained analytical data.

v. We ensured the Matplotlib window is properly sized during the visualization of the first second processed for detection.

vi. We plotted the image retrieved (returned_frame) as well as a pie chart to visualize the average count for each unique object detected in the last second of our video

vii. Finally, we created our video detection instance and set the parameters save_detected_video and return_detected_frame to False and True respectively.

When we run the above code, we should see the results below:

With the sample code above, we can obtain analytical data from video files. We can also use this code with live camera feeds using OpenCV, as well as store the generated analytical data in a database for future reference.

Visit the ImageAI Official English documentation to learn more about retrieving analytical data from videos and other features as well:

If you enjoyed this article, give it a clap. Also feel free to share it with friends and colleagues. You can reach to me if you have any questions or suggestions via my contacts below.

Twitter : https://twitter.com/OlafenwaMoses

Facebook: https://www.facebook.com/moses.olafenwa

Email: [email protected]

Website: https://moses.aicommons.science

Discuss this post on Hacker News and Reddit

Fritz

Our team has been at the forefront of Artificial Intelligence and Machine Learning research for more than 15 years and we're using our collective intelligence to help others learn, understand and grow using these new technologies in ethical and sustainable ways.

Comments 0 Responses

Leave a Reply

Your email address will not be published. Required fields are marked *

wix banner square