0

I've been given an image containing stars and ovals, and have been tasked with detecting which is which and counting how many of each are contained within the image. One such image with ovals only looks like this:

I've first tried to solve the problem using OpenCV using tutorials such as this one and this one.

However I seem to run into issues with both in bounding the ovals, one results in a count of 1 oval whereas another results in a count of 330.

I then tried using YOLOv4, thinking that it would be more useful when dealing with two different classes (stars and ovals). I used the following code from top try bound boxes on my sample image.

box, label, count = cv.detect_common_objects(img)
output = draw_bbox(img, box, label, count)
output = cv2.cvtColor(img, cv2.COLOR_BGR2RGB)
plt.figure(figsize= (10, 10))
plt.axis("off")
plt.imshow(img1)
plt.show()

However I received IndexError: Invalid index to scalar variable.

Can anyone point me in the right direction on how to proceed? I first need to be able to do it for one class, and then multiple classes, before expanding into doing it for several images automatically.

Thanks

Christoph Rackwitz
  • 11,317
  • 4
  • 27
  • 36

0 Answers0