Real time Shape Detection using Contours [9] | OpenCV Python Tutorials for Beginners 2020

Murtaza's Workshop - Robotics and AI · 168K views · 2019 · 20:24

Open on YouTube

Computer vision, speech & NLPPython, Ruby & scripting languagestutorial

Why Stack Overflow recommends it

Stack Overflow users link it when answering or asking about OpenCV contour detection, live shape detection, and its stackImages helper for combining images.

Recommended by 1 people across 1 different months, 2020 to 2021.

What it is

A beginner OpenCV Python tutorial by Murtaza Hassan that shows how to detect shapes by finding contours, counting corner points, and measuring area. It is part of a longer OpenCV series and includes a reusable image stacking helper from the course code.

What people said

Recommends Batuhan Tekmen · 2021-05 · Stack Overflow · on “How To Detect A Specific Mark On A Image Using OpenCv Python”

I guess it is a microscope output. First you have to detect (locate) objects in the image : My default solution would be object detection with machine learning models. This is the way if you have lots of labeled data (e.g annotated image). For example, you can train a YOLOv3 tiny model for this problem. Without diving into too much code, you can find the tutorial for detecting something different, and apply it to your problem. For example, you can follow this tutorial [LINK] , then you will ask more specific questions. If you are familiar with object detection with machine learning and frameworks like PyTorch and TensorFlow, you can find lighter models than YOLOv3 tiny from the GitHub [LINK]

Cites Phong Chu2612 · 2020-07 · Stack Overflow · on “Opencv can't show live webcam footage.What is wrong with my code?”

I want to display contour with live webcam feeding but it only show a frame. I'm aiming for something like this : [this video] code : import cv2 import numpy import math windowName = "OBJECT_MOVEMENT" cv2.namedWindow(windowName) cap = cv2.VideoCapture(0) if cap.isOpened(): ret, frame = cap.read() else: ret = False print("False operation.") while ret: ret, frame=cap.read() imgray = cv2.cvtColor(frame, cv2.COLOR_BGR2GRAY) ret, thresh = cv2.threshold(imgray,127,255,cv2.THRESH_BINARY) contours, hierarchy = cv2.findContours(thresh, cv2.RETR_TREE, cv2.CHAIN_APPROX_SIMPLE) finalIm = cv2.drawContours(frame, contours, -1, (0,255,0), 1) cnt = contours[0] M = cv2.moments(cnt) contours_sizes = [(cv2.contourA

Cites Apurva Sinha · 2021-06 · Stack Overflow · on “opencv python merge different channel images into one”

Here's the Python code for the same. It takes in images of any channel, but the width and height has to be maintained as is the case with hcontat, vcontat, hstack, vstack. scale: scales the final image by a given number imgArray: is the array of all the images you want to concatenate, no matter the channels in each of the images import numpy as np import cv2 def stackImages(scale,imgArray): rows = len(imgArray) cols = len(imgArray[0]) rowsAvailable = isinstance(imgArray[0],list) width = imgArray[0][0].shape[1] height = imgArray[0][0].shape[0] if rowsAvailable: for x in range(0,rows): for y in range(0, cols): if imgArray[x][y].shape[:2] == imgArray[x][y].shape[:2]: imgArray[x][y] = cv2.resize