I’m creating a python script that scans QR codes, and then processes the info in the code. The python-script will launch every few seconds via a timer in systemd on RBPI, but while scanning for a code – if no code has been detected in 5 seconds, the script should terminate. However, if a code is detected, the processing should
Tag: opencv
opencv error when converting a python file to an .exe file with pyinstaller
So I am trying to convert my python project to an exe file and run it, but when I do, I get an error like this: Failed to execute script ‘My project’ due to unhandled exception: ERROR recursion is detected during loading of “cv2” binary extensions. Check OpenCV installation. Here’s some of the code: any help would be appreciated. Answer
shrink and enlarge contour image with Python OpenCV
I have an image with an object like below: I can detect the contour and get a mask with only ball region, but my ROI is the edge region, that means I need a bigger and a smaller mask which combine to get this: so my question is: how can I shrink/enlarge the mask of contour around contour’s center? Answer
Loading YOLO: invalid index to scalar variable
Getting an error for IndexError: invalid index to scalar variable on the yolo_layers line. This code won’t work on my Jupyter notebook but will run fine on google collab. No idea why. Could be my python version? Answer It’s may caused by the different versions of cv2. The version of cv2 module with CUDA support will give you a 2-D
Python opencv/cvzone – UnboundLocalError
I am trying to make a ar mouse (camera vould detect your hand and than your finger vould be the mouse). But when checking which fingers are up I get an error. When making this program I followed this tutorial: https://www.youtube.com/watch?v=8gPONnGIPgw&t=332s. When doing that I made one thing different which is that I didn’t make a program file called HandTrackingModule.py
How to extract, modify and restore correctly modified bounding boxes
I’m trying to do relatively simple code where I extract contours of some areas in the image and draw 1 or multiple rectangles on them (normally with a “Object Detection model”) (works fine). However, I then need to transform the coordinates of the rectangles drawn on the cropped areas back to the original image (and draw them over it to
Replace cv2.warpPerspective for big images
I use python OpenCV to register images, and once I’ve found the homography matrix H, I use cv2.warpPerspective to compute final the transformation. However, it seems that cv2.warpPerspective is limited to short encoding for performance purposes, see here. I didn’t some test, and indeed the limit of image dimension is 32767 pixels so 2^15, which makes sense with the explanation
How to change pixel value based on a condition
The image is 1920 by 1080. How can I change the value of a pixel when a channel value is higher than the other? Here is what I did. Is there a more efficient way than iterating on each pixel? Answer Don’t use any loop for this, use ndarray capability and logical indexing. What you want to achieve is something
Remove white borders from segmented images
I am trying to segment lung CT images using Kmeans by using code below: The problem is the segmented lung still contains white borderers like this: Segmented lung (output): Unsegmented lung (input): The full code can be found in Google Colab Notebook. code. And sample of the dataset is here. Answer For this problem, I don’t recommend using Kmeans color
numpy.AxisError: axis 2 is out of bounds for array of dimension 0
I’m creating a program the requires a black and white image and two arrays containing the X and Y coordinates of both black and white pixels respectively. I have a program that utilizes OpenCV and binary thresholding to create a black and white image (code source). Hear is the code I have in full so far. The problem I have