#OpenCV #Python #Seeb4Coding count objects with OpenCV step-by-step tutorial for beginners with 3D animation: count coins (or any round object) in a photo with Python, OpenCV medianBlur and HoughCircles in 11 lines — tested, 24 out of 24. 💬 What would you count with this? Coins or cells? 👇 ❓ How do you count coins in an image with OpenCV? Load the image with cv2.imread, convert it to grayscale with cv2.cvtColor and smooth it with cv2.medianBlur. Then call cv2.HoughCircles with the HOUGH_GRADIENT method, a minimum distance between centres and a radius range; the number of returned circles is the coin count. On scikit-image's coins sample photo, blur 5, minDist 30, param2 22 and radius 12-45 found all 24 coins, while skipping the blur returned 29 circles including 5 false ones. Source: https://docs.opencv.org/4.x/da/d53/tutorial_py_houghcircles.html 🧭 Steps • Install: pip install opencv-python • Load the photo and convert it to grayscale (cv2.cvtColor) • Median blur (kernel 5) to remove noise • cv2.HoughCircles(blur, cv2.HOUGH_GRADIENT, 1, 30, param2=22, minRadius=12, maxRadius=45) • Draw a ring on each circle and print len(c) → Coins: 24 • Pro tip: no blur gave 29 circles (5 fake); param2 18 → 27, param2 25 → 22 ⏱ Chapters 0:00 Result: 24 coins counted 0:06 Step 1 · Load & clean (gray + median blur) 0:19 Step 2 · Find circles with HoughCircles 0:31 Step 3-4 · Draw, count & run 0:45 Pro tip: don't skip the blur 0:54 Recap Images: own demo output (scikit-image coins sample), OpenCV/Python logos via devicon About Seeb4Coding — Coding Meets Innovation Seeb4Coding (seeb4coding.in) is a tech education brand by Sweetan Mariyappan that explains the latest AI news with 3D animation and builds free online developer tools and coding tutorials. Website: https://seeb4coding.in YouTube: https://www.youtube.com/@sweetan008 Instagram: https://www.instagram.com/seeb4coding/ Threads: https://www.threads.com/@seeb4coding Facebook: https://www.facebook.com/groups/seeb4coding Personal: https://www.mrsweetan.in/ #OpenCV #Python #ComputerVision #ImageProcessing #PythonProjects #MachineVision #Seeb4Coding #CodingTutorial #LearnToCode #CodingMeetsInnovation #viral #goviral #trending
The information provided is not trading advice. kdj.com does not assume any responsibility for any investments made based on the information provided in this article. Cryptocurrencies are highly volatile and it is highly recommended that you invest with caution after thorough research!
If you believe that the content used on this website infringes your copyright, please contact us immediately (info@kdj.com) and we will delete it promptly.