<pre>import cv2 with open("annotationfile\\orange.txt") as iostream: content = iostream.read() color = (0, 0, 255) # RED for line in content.split("\\n"): image_path = "images\\orange.jpg" label, xmin, ymin, xmax, ymax = line.split(",") image = cv2.imread(image_path) pt1 = (int(xmin), int(ymin)) pt2 = (int(xmax), int(ymax)) cv2.rectangle(image, pt1, pt2, color) cv2.imshow("Visualization bounding box", image) cv2.waitKey() outfile = image_path\[:-4\] + "\_bbox.jpg" outimage = image\[int(ymin):int(ymax), int(xmin):int(xmax)\] cv2.imwrite(outfile, outimage)
I usually convert the txt format to a file, convert it to PDF and output from that file in any language, even Python. .
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)