Questions tagged [opencv]

20380 questions
0

votes
0

answer
2

Views

opencv Python PPF detector crash

I´ve noticed that the PPF3DDetector is now available in Python too. So I´ve tried to run this piece of sample code: ppf_load_match, but Python keeps chrashing when 'matching'. It takes a while to train the model, but you can increase the first argument of 'cv.ppf_match_3d_PPF3DDetector' to run it...
ZZM
1

votes
5

answer
1.2k

Views

Python add one more channel to image

I'm trying to add channel because of below error ValueError: could not broadcast input array from shape (48,48) into shape (48,48,1) Code: img = cv2.imread(f,0) resized = cv2.resize(img, (48,48), interpolation = cv2.INTER_AREA) print(resized.shape) (48, 48) But I need a channel image like (48,48,1...
Hasan Ramazan
1

votes
1

answer
4.4k

Views

Getting an error OpenCV(3.4.1) C:\projects\opencv-python\opencv\modules\imgproc\src\thresh.cpp:1406: error: (-215)

I ran the below code and I am getting an error as OpenCV(3.4.1) C:\projects\opencv-python\opencv\modules\imgproc\src\thresh.cpp:1406: error: (-215) src.type() == (((0) & ((1
SidAvenger
1

votes
1

answer
146

Views

How to make everything other than face transparent

I'm trying to extract the face from an image using opencv. Initially I'm converting the image to grayscale like so gray = cv2.cvtColor(image, cv2.COLOR_BGR2GRAY) Then I'm using dlib to generate facial points for me and then converting that to a numpy array and using fillconvexpoly method to get the...
Saikiran
-1

votes
0

answer
11

Views

What are the technologies I have to hire to make a AI based Camera APP for a Desktop?

(Note : if the question belong to different stackexhange notify me or mark for migration.Don't downvote ) Our decided to develop an application with below features The aim of the application is to dress a person using previously uploaded clothing materials who is standing before a display with camer...
Lord Commander
1

votes
1

answer
90

Views

How to save openCV classifier?

I want to save a classifier that has been trained on multiple images to avoid the time it takes to re-train it every time I run the program. For sklearn's classifiers I was able to simply pickle them, using pickle.load but when I try doing the same I get following error: TypeError: can't pickle cv2...
Ach113
1

votes
2

answer
294

Views

“Abort Trap: 6” when attempting OpenCV video capture on macOS Mojave

I've tried on both Python on C++, and every time I call cap.open(0), I get an Abort Trap: 6 error. I haven't been able to find any solutions to this via Google, and have tried reinstalling OpenCV several times now. Any suggestions?
bag531
1

votes
1

answer
1.3k

Views

OpenCV 4.0.0 SystemError: <class 'cv2.CascadeClassifier'> returned a result with an error set

Hello I am trying to create a facial recognition program but I have a peculiar error: here is my code: gray = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY) face_cascade = cv2.CascadeClassifier('lbpcascade_frontalface.xml') faces = face_cascade.detectMultiScale(gray, scaleFactor=1.2, minNeighbors=5); and thi...
Tyler Strouth
1

votes
2

answer
41

Views

How to feed OpenCV image to a trained CNN model(add a new dimension) in Python?

I'm getting this error Error when checking input: expected conv2d_11_input to have 4 dimensions, but got array with shape (300, 300, 3) How can I pass the RGB image to a CNN? How to enumerate samples to create a 4D image?
Arshad_221b
1

votes
3

answer
142

Views

Linking OpenCV 4.1.0, include works, libs doesn't

After changing Ubuntu from 16.04 to 18.04 and OpenCV from 3.4.1 to 4.1.0 i can't compiled... anything Step by step: I downloaded source code from github, set those flags: cmake -D CMAKE_BUILD_TYPE=RELEASE -D OPENCV_EXTRA_MODULES_PATH=~/opencv_contrib/modules cmake -DENABLE_PRECOMPILED_HEADERS=OFF -...
Fidor
1

votes
1

answer
87

Views

What is the difference between an opencv BGR image and its reverse version RGB image[:,:,::-1]?

I'm trying to show an opencv image with a QLabel. I got two different versions of the image, first one is the opencv BGR image, the second one is the RGB image using image[:,:,::-1], the BGR version works fine but the RGB version doesn't work. The following code works fine src = cv.imread('image.jpg...
Yifeng_Li
1

votes
3

answer
148

Views

How to use GPU to accelerate the processing speed of ffmpeg filter?

According to NVIDIA's developer website, you can use GPU to speed up the rendering of the ffmpeg filter. Create high-performance end-to-end hardware-accelerated video processing, 1:N encoding and 1:N transcoding pipeline using built-in > filters in FFmpeg Ability to add your own custom high-perform...
Zedd W
1

votes
1

answer
37

Views

Opencv showing wrong width and height of image

The question is in the title itself. I have an image with dimension 612x408 (widthxheight). When I open it using opencv cv2.imread(/path/to/img) it shows me (408,612,3). This is not the problem When I cv2.imshow() it shows the image correctly with width larger than height like a normal horizontal re...
Yusuf
1

votes
2

answer
39

Views

OpenCV, How to Join / Fill gap in lines or box or circles (Python)

I have a set of images which have boxes and circles contain numbers. Some boxes & circles are not connected across all sides, there some gap in lines. I want to fill this gap (shown in image), anyone has any idea using OpenCV...? My Code is here........ self.res = cv2.imread('1.jpg') self.store_path...
1

votes
1

answer
93

Views

OpenCV: Merging fitted shapes

If I'm using OpenCV (Python) and fit two shapes, like so: a = cv2.fitEllipse(contours) b = cv2.minAreaRect(contours) Both a and b are represented as Box2D objects, which look something like: center: (x, y) size: (width, height) rotation: angle a and b are often going to be fairly similar, but not ex...
Jordan
0

votes
0

answer
14

Views

how to find coordinates of the rectangles from image in python with opencv?

I have some imperfect rectangles in the image, I need set of coordinates for each rectangle in python using opencv I have tried Canny edge detection and the used findContours but it's giving more coordinates than required because rectangles are not having straight lines I have read similar questions...
komal thakkar
1

votes
1

answer
16

Views

I get TypeError: an integer is required (got type tuple) when trying to draw circle in cropped window

I looked through the other posts and nothings seems to fix my problem. As of now I can use mymouse_draw_rect function to draw a rectangle on my video stream and create a cropped window. I want to then further draw shapes in this cropped window, but when I try to call my select_point function my prog...
1

votes
0

answer
11

Views

In terms of time complexity, what is the most efficient way to overlay multiple smaller images onto a bigger image?

I am trying to overlay multiple smaller images onto a bigger background image using openCV. Currently I am using addWeighted() API with alpha=1.0 but this API only takes in two images. If img1 is overlaid onto img2 which is in turn overlaid onto img3, then I would have to call addWeighted() multiple...
Rahul Pradeep
1

votes
1

answer
380

Views

Canny Edge vs Thresholding for contour estimation in Open CV

I am using Open CV for an image processing application that involves contour estimation in images. What I would like to know is whether Thresholding the image (like how they have done here) or using Canny Edge Algorithm (here) yields a better result. Does this involve algorithmic analysis or am I m...
rhino2rhonda
1

votes
1

answer
1.2k

Views

iOS OpenCV cvtColor unknown array type error

I am starting with OpenCV on iOS and the first thing I wanted to achieve was transforming a colour image into a grey one. My first attempt was successful I was obtaining a Mat with 'CV_8UC1' option and then converting it back to a image. The code is as follows: UIImage *image = [UIImage imageNamed:...
Fawkes
0

votes
0

answer
4

Views

Android OpenCV copy ROI to part of bigger image

I get a mat (320x480) from the camera of the phone. Then I need to process a part of that frame. I use ROI for that: mat2 = new Mat(width, 175, CvType.CV_8SC3); Rect roi = new Rect(75, 0, 175, 320); mat2 = new Mat(mat1, roi); Now I want to create a new mat with dimensions 320x480 with a black backgr...
Anton
1

votes
1

answer
3.1k

Views

Limiting video capture frame rate on python and opencv

I am trying to capture video from ip camera and save as avi video file. At the same time script is saving the frames which contains faces as jpeg file. While script is doing these jobs cpu usage is about 100%. Because of this i want to limit frame rate only on face detection. My code is: face_cascad...
Kursat Serolar
1

votes
2

answer
1.5k

Views

OpenCV mean function crashes with mask created from OpenCV threshold function?

I'm very new to OpenCV, so I guess I'm making some silly mistake. First I'm creating an empty cv::mat matrix, mask, of CV_8U type and filling it with zeros. Then I'm filling the matrix with either 0's or 255's by checking the values in CV_32FC1 type cv::mat matrix croppedDifferenceImage by the use...
the_naive
0

votes
0

answer
4

Views

is there any way to use freenect.sync_get_video function with opencv VideoCapture function in python

i am trying to use libfreenect function sync_get_video() that grab rgb frames to use with open cv video capture function is there any possible way of doing it in python? i know that we can compile opencv with OpenNI and use that function but i don't want to use that for some reason. my current cod...
Arsii Rasheed
0

votes
0

answer
18

Views

Why my code is showing assertion error and value error?

I m trying to resize my image. for this i'm using resize from skimage. For this the input will be 3d numpy array of images. And output will again be a 3d numpy array of smaller dimension. downSample = [] for i in range(len(rgb_val)): downSample.append(resize(rgb_val[i], (rgb_val[i].shape[0] / 16, r...
Rishabh Ojha
1

votes
0

answer
17

Views

Function I have wrote for Convolution giving error

I have written a code for Convolution, but it is not giving proper output. Code: def convolve(img , kernel): (ih , iw) = img.shape[:2] (kh , kw) = kernel.shape[:2] pad = (kw - 1) // 2 img = cv2.copyMakeBorder(img , pad , pad , pad , pad , cv2.BORDER_REPLICATE) out = np.zeros((ih , iw) , dtype = 'flo...
Anjali Singh
0

votes
1

answer
16

Views

Add chroma noise to image

I'm training a deep neural network to improve the quality of images. The images contain some specific types of noise that I want to reduce/remove by means of a deep learning model. In order to do so I'm using a huge dataset of similar clear high-res images with barely any noise, add the specific typ...
Hendrik Wiese
1

votes
1

answer
388

Views

Find the perimeter of the leaf

Here is a leaf I want to find the length of it's periphery i.e. it's perimeter using openCV and Python.I tried writing a code but it is not giving the desired result.I have to reset the threshold for every example and also it's not giving a closed contour.I want it to be a generalized code to work o...
Muskan Bansal
1

votes
2

answer
62

Views

Why doesn't python openCV change colors the way I expect it to?

I am just starting out with opencv in python3(or any language for that matter). I am on windows 10. Here is my pip freeze: numpy==1.16.0 opencv-python==4.0.0.21 Wand==0.5.0 I am trying to change every color pixel except for (BGR notation)[255,142,0] to black. Here is my test code import cv2 import n...
fozbstuios
1

votes
3

answer
98

Views

Capturing a SINGLE image from an rtsp H.264 video stream

I'm trying to capture a single image on demand from an RTSP H.264 video frame. I'm using OpenCV with Python running on a Raspberry Pi. My understanding is that you can't simply capture an image, but rather must constantly read the stream of images from the video and discard all but the occasional...
FarNorth
1

votes
2

answer
244

Views

Moroccan License Plate Recognition (LPR) using OpenCV and Tesseract

I'm working on a project about recognizing moroccan license plates which look like this image : Moroccan License Plate Please how can I use OpenCV to cut the license plate out and Tesseract to read the numbers and arabic letter in the middle. I have looked into this research paper : https://www.rese...
Soufiane Sabiri
1

votes
2

answer
86

Views

How to use cv::Mat and Eigen::Matrix correctly? (OpenCV + Eigen)

I am able to convert an OpenCV mat object to an Eigen object, and back. However when I try to display the Eigen->Mat on the screen I get a blank window, and I do not know why. I can save the image to a file so I know its converting correctly. Any suggestions on how to get the converted image to dis...
user2840470
1

votes
1

answer
47

Views

How does np.outer help in creating a filter kernel?

I was trying the filter2D function with OpenCV using my own kernel: kernel = np.array([1,3,4,5,2]) / 11 cv2.filter2D(img, -1, kernel) and it works fine. I also saw a snippet where the same thing was done as follows: kernel = np.array([1,3,4,5,2]) / 11 kernel = np.outer(kernel, kernel) cv2.filter2D(i...
Sophia
1

votes
1

answer
33

Views

Using gaussian blur with zero size kernel?

I was reading about Gaussian Blur when one of the examples I came across was as follows: cv2.GaussianBlur(img, (0,0), 5) What does 0,0 mean here? This is in sharp contrast to another example I read: cv2.GaussianBlur(img,(5,5),0) How are both different from each other?
Harris Pat
1

votes
1

answer
70

Views

What does the TM_CCORR and TM_CCOEFF in opencv mean?

What does the TM_CCORR and TM_CCOEFF in opencv mean? I found that TM_CCORR stands for the correlation coefficient. However, the TM_CCOEFF seams also to be the correlation coefficient due to its naming. Do you know for what the abbrevations stand? TM_SQDIFF = Template Matching Square Difference TM_CC...
Rene B.
3

votes
1

answer
444

Views

How can I install Dlib in a Heroku python web app using requirements.txt?

I built a Python Flask web API that involves machine learning and I've had a lot of frustration deploying it on Heroku. The problem is, my app has a dependency on Dlib ( a library) and I can't seem to find a way to install in my Heroku server. I'm losing my mind trying to fix this and I can imagine...
Nuelsian
1

votes
0

answer
6

Views

Is there any way to improve contour detection of pupil area from a cartesian iris image?

So, I have this Iris images that i turned into a cartesian images including the pupil area. Now the problem is I need to remove the pupil area from the image. (the pupil area/size are different for each image) I've tried to mask the pupil area by doing a threshold and finding the contour of the pupi...
kchalim
0

votes
0

answer
17

Views

How to install old version of library in Pip3

I would like to use opencv-python and opencv-contrib-python versions in 3.3 or below on Python 3.7. The issue is that I can't seem to get them on pip3. I need it to be pip3 and Python 3.7 because it's to run on Google Cloud Functions. If I run $ pip3 install opencv-contrib-python== to get the versio...
Anters Bear
0

votes
0

answer
12

Views

Row filtering of the image

I am writing the row filtering process of the image and got the following errors. OpenCV(3.4.1) Error: Assertion failed ((unsigned)pt.y < (unsigned)size.p[0]) in cv::Mat::at, file c:\opencv\3.4.1\build\install\include\opencv2\core\mat.inl.hpp, line 1128 I add padding to the image using the copyMakeB...
Min Thae Hua
1

votes
0

answer
118

Views

zbar not working on netcat video stream from raspberry pi read using OpenCV

I am streaming video feed from raspberry pi using netcam to my PC and using zbar to read qr codes i the feed. I am reading the named pipe using ffmpeg: FFMPEG_BIN = 'ffmpeg' command = [ FFMPEG_BIN, '-i', 'fifo264', # fifo is the named pipe '-pix_fmt', 'gray', # opencv requires bgr24...
Snehil Vijay

View additional questions