Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Simp!a nhianto - Page 1 of 2 An example of an input image: The output image with the corresponding text: def label _ specific _

Simp!a nhianto-
Page 1 of 2
An example of an input image:
The output image with the corresponding text: def label_specific_objects(detected_shapes, image):
labels =[]
used =[False]* len(detected_shapes)
for i,(shape, color, contour, cX, cY) in enumerate(detected_shapes):
if used[i]:
continue
label = "unknown"
if shape == "triangle":
for j,(other_shape, other_color, other_contour, other_cX, other_cY) in enumerate(detected_shapes):
if not used[j] and other_shape == "rectangle" and are_contours_close(contour, other_contour):
used[i]= used[j]= True
label = "Tree Class 1"
break
if shape == "circle":
for j,(other_shape, other_color, other_contour, other_cX, other_cY) in enumerate(detected_shapes):
if not used[j] and other_shape == "rectangle" and are_contours_close(contour, other_contour):
used[i]= used[j]= True
label = "Tree Class 2"
break
if shape == "rectangle":
for j,(other_shape, other_color, other_contour, other_cX, other_cY) in enumerate(detected_shapes):
if not used[j] and other_shape == "circle" and are_contours_close(contour, other_contour):
for k,(third_shape, third_color, third_contour, third_cX, third_cY) in enumerate(detected_shapes):
if not used[k] and third_shape == "triangle" and are_contours_close(contour, third_contour):
used[i]= used[j]= used[k]= True
label = "House Class 1"
break
if shape == "triangle":
for j,(other_shape, other_color, other_contour, other_cX, other_cY) in enumerate(detected_shapes):
if not used[j] and other_shape == "square" and are_contours_close(contour, other_contour):
for k,(third_shape, third_color, third_contour, third_cX, third_cY) in enumerate(detected_shapes):
used[i]= used[j]= True
label = "House Class 2"
break
if shape == "triangle":
for j,(other_shape, other_color, other_contour, other_cX, other_cY) in enumerate(detected_shapes):
if not used[j] and other_shape == "rectangle" and are_contours_close(contour, other_contour):
for k,(third_shape, third_color, third_contour, third_cX, third_cY) in enumerate(detected_shapes):
if not used[k] and third_shape == "rectangle" and are_contours_close(contour, third_contour):
for l,(fourth_shape, fourth_color, fourth_contour, fourth_cX, fourth_cY) in enumerate(detected_shapes):
if not used[l] and fourth_shape == "circle" and are_contours_close(contour, fourth_contour):
for m,(fifth_shape, fifth_color, fifth_contour, fifth_cX, fifth_cY) in enumerate(detected_shapes):
if not used[m] and fifth_shape == "circle" and are_contours_close(contour, fourth_contour):
used[i]= used[j]= used[k]= used[l]= used[m]= True
label = "Car"
break
if label == "Car":
break
if label == "Car":
break
if shape == "triangle":
for j,(other_shape, other_color, other_contour, other_cX, other_cY) in enumerate(detected_shapes):
if not used[j] and other_shape == "rectangle" and are_contours_close(contour, other_contour):
for k,(third_shape, third_color, third_contour, third_cX, third_cY) in enumerate(detected_shapes):
if not used[k] and third_shape == "rectangle" and are_contours_close(contour, third_contour):
for l,(fourth_shape, fourth_color, fourth_contour, fourth_cX, fourth_cY) in enumerate(detected_shapes):
if not used[l] and fourth_shape == "circle" and are_contours_close(contour, fourth_contour):
for m,(fifth_shape, fifth_color, fifth_contour, fifth_cX, fifth_cY) in enumerate(detected_shapes):
if not used[m] and fifth_shape == "circle" and are_contours_close(contour, fifth_contour):
used[i]= used[j]= used[k]= used[l]= used[m]= True
label = "Truck"
break
modify this code and solve the errors
image text in transcribed

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Students also viewed these Databases questions