ตัวอย่างรหัสเพื่อสร้างกล่องขอบเขต
ไม่เข้าใจวิธีการวาดกล่องขอบเขตรอบวัตถุในภาพสําหรับแอปพลิเคชันการตรวจจับวัตถุแบบกําหนดเอง
ตัวอย่างรหัสสําหรับการสร้างกล่องขอบเขต:
For box in boxes:
#Pick a confidence factor from the last place in an array.
conf=box[-1]
If conf > threshold:
#Convert float to int and multiply corner position of each box by x and y ration.
#If the bounding box is found that the top of the image
#Position the upper box bar little lower to make it visible on the image
(x_min, y_min, x_max, y_max) = [
int (max(corner_position*ratio_y, 10)) if idx%2
else int (corner_position*ratio_x)
for idx, corner_position in enumerate(box[:-1])
#Draw a box base on the position, parameters in rectangle function are: image,start_point, end_point, color, thickness.
rgb_image = cv2.rectangle(rgb_image, (x_min,y_min), (x_max,y_max),
colors["green"], 3)
โปรดดูรหัสแหล่งที่มาของการ ตรวจจับวัตถุ Python* เพื่อเรียนรู้การใช้งาน OpenVINO™ Inference Engine API สําหรับการสร้างกล่องขอบเขตและวิธีจัดการกับโมเดล