0

I'm trying to draw a convex hull on random points but I have to do this using with opencv - not convexhull command or scpiy or hull lib)

  • First step, I create random points between 14 - 20 numbers.

  • However, I need something like this.

    How can I save the plt.show() resultant graphic and draw convex hull like that?

Here's my code:

import random
import matplotlib.pyplot as plt
import cv2
points = []
points_limit = 12+random.randint(0, 7)
print(points_limit)

for x in range(points_limit):
    points.append([random.randint(0, 9),random.randint(0, 9)])

print(points)

for point in points:
   plt.scatter(point[0],point[1], color='k', s=100)

print(points)
plt.show()
Atakan ADA
  • 95
  • 1
  • 1
  • 8
  • Why don't you draw the convex hull as in [your previous question](https://stackoverflow.com/questions/62376042/calculating-and-displaying-a-convex-hull)? Opencv is meant for computer vision. – JohanC Jun 15 '20 at 11:11
  • @JohanC first of all thank you for answer about previous question. But i have to proof in to my dissertation at school about this question with convex hull and with opencv. – Atakan ADA Jun 15 '20 at 11:17
  • So, did you try openCv's [`cv.convexHull`](https://docs.opencv.org/2.4/modules/imgproc/doc/structural_analysis_and_shape_descriptors.html?highlight=convexhull#convexhull)? What did or didn't work as expected? How did you try to solve these problems? – JohanC Jun 15 '20 at 11:34
  • @JohanC first step , i have to save this graphic as a image and use with cv2.imread . Then " points " had a random points coordinates. I think , i can draw convex hull with between two points slope or step by step draw with outside points coordinates. If i'm wrong please tell me the correct . – Atakan ADA Jun 15 '20 at 11:43
  • @JohanC Your previous answer is working really great by the way. – Atakan ADA Jun 15 '20 at 11:49

0 Answers0