opencv

Find countors on a dark background

Find countours on a dark background Question: Suppose, I have a dark image on a white background. For example, the image below: With the code below, I can easily extract its countors import imutils import cv2 image = cv2.imread("image.jpg") image = cv2.cvtColor(image, cv2.COLOR_BGR2GRAY) image = imutils.resize(image, width = 64) thresh = cv2.adaptiveThreshold(image, 255, cv2.ADAPTIVE_THRESH_MEAN_C, cv2.THRESH_BINARY_INV, …

Total answers: 2

Triangulated points are shifted and rotated but reasonable otherwise

Triangulated points are shifted and rotated but reasonable otherwise Question: I have two different views of a football game, I use a 2d pose estimator on both views to get 2d poses and then I map the different 2d poses(currently by hand) in the two different cameras such that I know the corresponding poses. I …

Total answers: 1

how to get a image from large video using opencv

how to get a image from large video using opencv Question: My code run very well. But this process is tiring my processor. I have 1000+ videos to make it Is there anyone to have more useful code? import cv2 video = cv2.VideoCapture("E:/videos/example1.mp4") length = int(video.get(cv2.CAP_PROP_FRAME_COUNT)) video.get(cv2.CAP_INTELPERC_IMAGE_GENERATOR) print( length ) i=0 while True: ret, frame …

Total answers: 1

Live OpenCV window capture (screenshot) on macOS (Darwin) using Python

Live OpenCV window capture (screenshot) on macOS (Darwin) using Python Question: I am following a tutorial on Open CV and trying to rewrite the following code: https://github.com/learncodebygaming/opencv_tutorials/tree/master/005_real_time (specifically, the windowcapture.py file) This file uses win32gui, win32ui, win32con to capture a given open window by window name and take a screenshot of it for cv2 processing …

Total answers: 1

How to draw bounding boxes using normalized bounding polygon vertices?

How to draw bounding boxes using normalized bounding polygon vertices? Question: I am using the localization module of Google Vision API and I am getting normalized vertices as the response. I want to draw bounding boxes over these objects but I am not able to reach a solution. Response returned: Top (confidence: 0.8741532564163208) Normalized bounding …

Total answers: 1

How to save image to binary format in python?

How to save image to binary format in python? Question: I am trying to convert image to binary using python, but something is not working properly. Here is my code: def binarize_image(filename): filename = MEDIA_ROOT + "\" + filename img = cv2.imread(filename) greyscale_img = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY) binary_img = cv2.threshold(greyscale_img, 127, 64, cv2.THRESH_BINARY,) resized_name = f"binary_{filename[:len(filename) …

Total answers: 1

OpenCV functions specifically built for uint8 datatype

OpenCV functions specifically built for uint8 datatype Question: I am using the cv2.calcOpticalFlowFarneback() function in Python to calculate the optical flow between two images and find the translation vector between the two displaced images. The images which I’m using have been generated by an atomic force microscope, which gives resolutions for each pixel value significantly …

Total answers: 1

Why do edge detection results look different for uint8 and float32?

Why do edge detection results look different for uint8 and float32? Question: I use OpenCV’s Sobel filter for edge detection. I was wondering why the output looks different when I run the 2 following lines. # uint8 output img_uint8 = cv2.Sobel(img_gray, cv2.CV_8U, dx=1, dy=0, ksize=5) # float32 output img_float32 = cv2.Sobel(img_gray, cv2.CV_32F, dx=1, dy=0, ksize=5) …

Total answers: 1

OpenCV, editing an image list directly leads to inaccuracies

OpenCV, editing an image list directly leads to inaccuracies Question: I was learning OpenCV with python, and tried to edit a section of pixels in an image. import cv2 img1 = cv2.imread(‘Assets/chess.jpg’, 1) for row in range(20, 50): for column in range(20, 50): img1[row][column] = [255, 0, 0] cv2.imwrite(‘Assets/new_chess.jpg’, img1) In the code I am …

Total answers: 1