opencv

How to effectively loop through each pixel for saving time with numpy?

How to effectively loop through each pixel for saving time with numpy? Question: As you know looping through each pixels and accessing their values with opencv takes too long. As a beginner I’m trying to learn opencv myself when I tried this approach it took me around 7-10 seconds of time to loop through image …

Total answers: 3

Find out how much of a rectangle is filled with a color using OpenCV

Find out how much of a rectangle is filled with a color using OpenCV Question: I am using a webcam to segment a green piece of paper. I have tried different results using inRange and thresholding but have gotten a pretty good result so far. I now have a rectangle in the middle of the …

Total answers: 1

How to crop square inscribed in partial circle?

How to crop square inscribed in partial circle? Question: I have frames of a video taken from a microscope. I need to crop them to a square inscribed to the circle but the issue is that the circle isn’t whole (like in the following image). How can I do it? My idea was to use …

Total answers: 3

How can I identify objects inside the image using python opencv?

How can I identify objects inside the image using python opencv? Question: I’m trying to identify objects present inside the plane area as in below image for some automation image1 for this I tried finding the contours on masked image obtained using thresholding the hsv range of object border colors which is yellowish then I …

Total answers: 1

batch_distance.cpp:274: error: (-215:Assertion failed)

batch_distance.cpp:274: error: (-215:Assertion failed) Question: ` I have the following code : import cv2 import os from os import listdir import numpy as np from PIL import Image from tabulate import tabulate import itertools #sift sift = cv2.SIFT_create() #feature matching bf = cv2.BFMatcher(cv2.NORM_L2, crossCheck=True) # get the path/directory folder_dir = "./runs/myDetect/SIFT" col_names = [] data …

Total answers: 1

How to connect broken lines in binary image using OpenCV/Python

How to connect broken lines in binary image using OpenCV/Python Question: I have images like the following one and the lines are broken. I have tried to connect them using morphological operations but it’s not effective. I’ve also thought of calculating orientation but since lines are parallel I can not do this. Is there a …

Total answers: 1

open-cv installation in docker image does not work on raspberry pi

open-cv installation in docker image does not work on raspberry pi Question: I have created python project with some dependencies, among them open-cv. Now I want to deploy my project in a docker image. For this, I created the following build-file on my local machine (running Ubuntu 22.04): # syntax=docker/dockerfile:1 FROM python:3.8-slim-buster WORKDIR /app COPY …

Total answers: 1

Using custom yolov7 trained model on my screen

Using custom yolov7 trained model on my screen Question: What I know I have already trained a custom model using yolov7-tiny I am now trying to use it for object detection on screen The script I have: import mss import numpy as np import cv2 import time import keyboard import torch from hubconf import custom …

Total answers: 1

Saving captured frames to separate folders

Saving captured frames to separate folders Question: Currently working on extracting frames from videos and have noticed that the images get overwritten. Would be nice to create a folder for each of the captured frames but I’m unsure how to do that. data_folder = r"C:UsersjagacDownloadsData" sub_folder_vid = "hmdb51_org" path2videos = os.path.join(data_folder, sub_folder_vid) for path, subdirs, …

Total answers: 1

image is too big for OpenCV imshow window, how do I make it smaller?

image is too big for OpenCV imshow window, how do I make it smaller? Question: I’m comparing two images – a complete image & a small part of the same image. If a match is found, then a rectangular box is drawn around that part of the image which contains the smaller image. To implement …

Total answers: 1