I am recieving this error when running this line of code: OpenCV(4.1.2) C:projectsopencv-pythonopencvmodulesimgprocsrcresize.cpp:3720: error: (-215:Assertion failed) !ssize.empty() in function ‘cv::resize’ Answer Your img variable is empty, you probably didn’t load the image correctly. Try printing your img.shape after you load your image. Then have a look at the path you specified, there is probably something wrong with it. (Either you
Tag: opencv
Canny edge detection not working on Gaussian blurred images
I am trying to detect edges on this lane image. First blurred the image using Gaussian filter and applied Canny edge detection but it gives only blank image without detecting edges. I have done like this: Answer You should always examine your data. Simply running your script step by step and examining intermediate values shows what is going wrong: mpimg.imread
Error:module ‘cv2.cv2’ has no attribute ‘STEREO_BM_BASIC_PRESET’
I am trying to get the depth map of two stereo images but error ‘cv2.cv2’ has no attribute ‘STEREO_BM_BASIC_PRESET’ occurred. the code: Answer solved worked with OpenCV 4.
Get In Focus Pixels of an Image
How to detect which pixels of an image are in focus compared to the blurry ones. Something like the ‘Focus Peaking’ feature lots of cameras have? The idea is to color the pixels that are in focus so that it assists the user while clicking a picture. Looking for an implementation through Python. Answer You can find the edges, which
Python loadarff fails for string attributes
I am trying to load an arff file using Python’s ‘loadarff’ function from scipy.io.arff. The file has string attributes and it is giving the following error. How to read the arff successfully? Answer Since SciPy’s loadarff converts containings of arff file into NumPy array, it does not support strings as attributes. In 2020, you can use liac-arff package. However, make
How to decode a video (memory file / byte string) and step through it frame by frame in python?
I am using python to do some basic image processing, and want to extend it to process a video frame by frame. I get the video as a blob from a server – .webm encoded – and have it in python as a byte string (b’x1aExdfxa3xa3Bx86x81x01Bxf7x81x01Bxf2x81x04Bxf3x81x08Bx82x88matroskaBx87x81x04Bx85x81x02x18Sx80gx01xffxffxffxffxffxffxffx15Ixa9fx99*xd7xb1x83x0fB@Mx80x86ChromeWAx86Chromex16Txaekxadxaexabxd7x81x01sxc5x87x04xe8xfcx16t^x8cx83x81x01x86x8fV_MPEG4/ISO/AVCxe0x88xb0x82x02x80xbax82x01xe0x1fCxb6ux01xffxffxffxffxffxff …). I know that there is cv.VideoCapture, which can do almost what I need.
Understanding contour hierarchies: How to distinguish filled circle/contour and unfilled circle/contour in OpenCV?
I am unable to differentiate between the below two contours. cv2.contourArea() is giving the same value for both. Is there any function to distinguish them in Python? How do I use contour hierarchies to determine the difference? Answer To distinguish between a filled contour and unfilled contour, you can use contour hierarchy when finding contours with cv2.findContours(). Specifically, you can
How to replace all pixels of a certain RGB value with another RGB value in OpenCV
I need to be able to replace all pixels that have a certain RGB value with another color in OpenCV. I’ve tried some of the solutions but none of them worked for me. What is the best way to achieve this? Answer TLDR; Make all green pixels white with Numpy: I have made some examples of other ways of changing
How to convert a video (on disk) to a rtsp stream
I have a video file on my local disk and i want to create an rtsp stream from it, which i am going to use in one of my project. One way is to create a rtsp stream from vlc but i want to do it with code (python would be better). I have tried opencv’s VideoWritter like this But
Python split image into multiple pieces by horizontal dashed lines
I have a bunch of image like this one: Where the yellow box are contents of different profiles (text), where each section is divided by the dashed lines (no the straight lines). So what I need is to split the image into multiple single images by the dashed lines. So far I have tried a lot of python and cv2