Nekshay commited on
Commit
897f510
1 Parent(s): 8ad5847

Create tem.txt

Browse files
Files changed (1) hide show
  1. tem.txt +23 -0
tem.txt ADDED
@@ -0,0 +1,23 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import cv2
2
+
3
+ # Load the original image
4
+ image_path = 'path/to/your/image.jpg'
5
+ image = cv2.imread(image_path)
6
+
7
+ # Bounding box coordinates in (center_x, center_y, height, width) format
8
+ bbox_center = [0.5, 0.5, 0.4, 0.3]
9
+
10
+ # Convert to top-left and bottom-right coordinates
11
+ center_x, center_y, height, width = bbox_center
12
+ top_left_x = int((center_x - width / 2) * image.shape[1])
13
+ top_left_y = int((center_y - height / 2) * image.shape[0])
14
+ bottom_right_x = int((center_x + width / 2) * image.shape[1])
15
+ bottom_right_y = int((center_y + height / 2) * image.shape[0])
16
+
17
+ # Draw the bounding box on the image
18
+ cv2.rectangle(image, (top_left_x, top_left_y), (bottom_right_x, bottom_right_y), (0, 255, 0), 2)
19
+
20
+ # Display the image with the bounding box
21
+ cv2.imshow('Image with Bounding Box', image)
22
+ cv2.waitKey(0)
23
+ cv2.destroyAllWindows()