How to use 'bounding box opencv python' in Python

Every line of 'bounding box opencv python' code snippets is scanned for vulnerabilities by our powerful machine learning engine that combs millions of open source libraries, ensuring your Python code is secure.

All examples are scanned by Snyk Code

By copying the Snyk Code Snippets you agree to
this disclaimer
7def boxing(original_img, predictions):
8 newImage = np.copy(original_img)
9 car = 0
10 truck = 0
11 motorbike = 0
12 for result in predictions:
13 if result['label'] == 'car' or result['label'] == 'motorbike' or result['label'] == 'truck':
14 if result['label'] == 'car':
15 car = car + 1
16 if result['label'] == 'motorbike':
17 motorbike = motorbike + 1
18 if result['label'] == 'truck':
19 truck = truck + 1
20
21
22 top_x = result['topleft']['x']
23 top_y = result['topleft']['y']
24
25 btm_x = result['bottomright']['x']
26 btm_y = result['bottomright']['y']
27
28 confidence = result['confidence']
29 label = result['label'] + " " + str(round(confidence, 3))
30
31 if confidence > 0.3:
32 newImage = cv2.rectangle(newImage, (top_x, top_y), (btm_x, btm_y), (255,0,0), 2)
33
34 print ("cars : {}".format(car))
35 print ("trucks : {}".format(truck))
36 print ("motorbike : {}".format(motorbike))
37 print ('\n')
38 return newImage
Important

Use secure code every time

Secure your code as it's written. Use Snyk Code to scan source code in minutes – no build needed – and fix issues immediately. Enable Snyk Code


Related snippets