OpenCV প্ল্যাটফর্ম পাইথনের জন্য cv2 লাইব্রেরি প্রদান করে। এটি বিভিন্ন আকার বিশ্লেষণের জন্য ব্যবহার করা যেতে পারে যা কম্পিউটার দৃষ্টিতে দরকারী। এই নিবন্ধে আমরা ওপেন সিভি ব্যবহার করে একটি বৃত্তের আকৃতি চিহ্নিত করব। এর জন্য আমরা cv2.HoughCircles() ফাংশন ব্যবহার করব। Hough ট্রান্সফর্ম ব্যবহার করে একটি গ্রেস্কেল ইমেজে সার্কেল খুঁজে বের করে। নীচের উদাহরণে আমরা ইনপুট হিসাবে একটি চিত্র নেব। তারপর এটির একটি অনুলিপি তৈরি করুন এবং আউটপুটে বৃত্ত সনাক্ত করতে এই রূপান্তর ফাংশনটি প্রয়োগ করুন৷
সিনট্যাক্স
cv2.HoughCircles(image, method, dp, minDist) Where Image is the image file converted to grey scale Method is the algorithm used to detct the circles. Dp is the inverse ratio of the accumulator resolution to the image resolution. minDist is the Minimum distance between the center coordinates of detected circles.
উদাহরণ
নীচের উদাহরণে আমরা আমাদের ইনপুট ইমেজ হিসাবে নীচের ছবিটি ব্যবহার করি। তারপর চেনাশোনাগুলি পেতে নীচের প্রোগ্রামটি চালান৷

নীচের প্রোগ্রামটি একটি চিত্র ফাইলে বৃত্তের উপস্থিতি সনাক্ত করে। যদি বৃত্ত উপস্থিত থাকে তবে এটি হাইলাইট করে।
উদাহরণ
import cv2
import numpy as np
image = cv2.imread('circle_ellipse_2.JPG')
output = image.copy()
img = cv2.cvtColor(image, cv2.COLOR_BGR2GRAY)
# Find circles
circles = cv2.HoughCircles(img, cv2.HOUGH_GRADIENT, 1.3, 100)
# If some circle is found
if circles is not None:
# Get the (x, y, r) as integers
circles = np.round(circles[0, :]).astype("int")
print(circles)
# loop over the circles
for (x, y, r) in circles:
cv2.circle(output, (x, y), r, (0, 255, 0), 2)
# show the output image
cv2.imshow("circle",output)
cv2.waitKey(0) উপরের কোডটি চালানো আমাদের নিম্নলিখিত ফলাফল দেয় -
আউটপুট
[[93 98 84]]
এবং আমরা নীচের চিত্রটি আউটপুট দেখাচ্ছে।
