Toolkit v1.5.1b0 released

93 views
Skip to first unread message

Takenori Sato

unread,
Jun 18, 2020, 12:07:41 AM6/18/20
to EDGEMATRIX Stream Toolkit Forum
We are please to announce that we released the Toolkit v1.5.1 with the following new features. These new features will work together with the Device Console so that your app could allow an end user to define arbitrary lines or polygons for line counting and/or intrusion detection, etc.

New Features

  • drawing lines with custom overlay
  • detect if an object is inside a region or not
drawing lines with custom overlay

Now that custom overlay feature supports lines in addition to texts and rectangles, you can use the following line structure to draw lines.

'line_params': [
             
'x1',
             
'y1',
             
'x2',
             
'y2',
             
'line_width',
             
'line_color_red',
             
'line_color_green',
             
'line_color_blue',
             
'line_color_alpha'
]


detect if an object is inside a region or not

To efficiently achieve this task, we have allowed the following imports in a callback.

from cv2 import pointPolygonTest
from numpy import array

Then, this can be used together with an array of points defined and passed by Options as follows.

Definition in an app

    "options": [
        {
            "key": "measurement_area",
            "option_type": "callback",
            "value_type": "list"
        },
        {
            "key": {
                "element": "aimeta",
                "property": "signal-interval"
            },
            "option_type": "gstreamer",
            "value_type": "number"
        }
    ]

User defined value in a stream config

  "options": [
   
{
     
"key": {
       
"element": "aimeta",
       
"property": "signal-interval"
     
},
     
"value": 10
   
},
   
{
     
"key": "measurement_area",
     
"value": [[630, 360], [850, 360], [850, 560], [630, 560]]
   
}
 
]


Detection implementation in a callback

def check_area_entrance():
   
for car in tracking_dict.values():
       
if car.measurement_area_entered_time() != 'N/A':
           
# already entered
           
continue
       
if is_car_entered(car):
            car
.mark_measurement_area_entered()


def is_car_entered(car):
   
global debug_string
   
# Rectangle params
    last_rect
= car.last_rect
    left
= last_rect["left"]
    top
= last_rect["top"]
    width
= last_rect["width"]
    height
= last_rect["height"]
    c_x
= left + (width // 2)
    c_y
= top + (height // 2)


   
# Polygon params
    n_pts
= len(measurement_area)
    pts
= array(measurement_area)
    pts
= pts.reshape((-1,n_pts, 2))


   
# Check if the center of the rectangle is inside the polygon:
   
# -1: out of the polygon
   
#  0: on the polygon's edge
   
#  1: inside the polygon
    result
= pointPolygonTest(pts, (c_x, c_y), False)
    inside
= (result > 0)
    debug_string
= debug_string + '\ncar ' + str(car.car_id) + ' at ' + str(last_rect) + ' is inside? ' + str(inside)
   
return inside

Template App

To demonstrate these new  features, the EMI Vehicle Counter template and vehicle_stream have been updated. You can get the latest version of toolkit_home_v1.1.1 from here on the Google Drive.

Screenshot 1: The car id 75 has entered the region.


75_entered.png


Screenshot 2: The car id 75 has a timestamp when its center has entered the region, other cars have "N/A".

marked.png


Device Console Integration

The Device Console will automagically find available lines or polygons in options, then let an end user draw such object on a screen. Such configuration will be saved in a stream config, then which will be accessible to your app.

In order for the Device Console to find such lines or polygons, please make sure to add a prefix, "line" for lines, and "polygon" for polygons, to keys. 
Reply all
Reply to author
Forward
0 new messages