I seem to be having an issue capturing images with OpenCv on my Pi 4 Buster. When I try to capture an image using OpenCV, it comes out like this:
Image Captured via OpenCV
Anyone know what may be causing the image to appear this way?
I have tested the camera using the raspistill command, the image appears as it should when I do this. I have been using OpenCV version 2.4.9.1 on Pi 3 Stretch for several years without issue. I am currently trying to upgrade to Pi 4 Buster. When I cloned OpenCV from Github onto the Pi 4 Buster, it gave me version 2.4.13.7. I don't want to switch to a newer version of OpenCV because I'm sure it will break everything else that works.
I am trying to do object detection using YOLO from the official website:https://pjreddie.com/darknet/yolo/
But I cannot integrate OpenCV with it though I have already install OpenCV in my both python version python and python3
her is the error:
rajan#RGR:~/darknet$ ./darknet detector demo cfg/coco.data cfg/yolov3.cfg yolov3.weights videosample.mp4
Demo needs OpenCV for webcam images.
so can anyone help me to solve this, I have been trying to solve it for more than a week but I could not do it. I would be glad if someone gives me the solution. thank you in advance.
Hi. You should opencv =1 in makefile, and make again
if you want to test on a video then type
./darknet detector demo cfg/obj.data cfg/yolo-tiny-obj.cfg
backup/yolo-tiny-obj_40000.weights data/test.mp4
or you can upgrade your opencv
I need some help converting a cpp file to a mex file.
I get the error below:
fatal error: opencv2/core/core.hpp: No such file or directory
Compilation terminated
The cpp file is using opencv header files. I'm not sure how to link Matlab with opencv in Ubuntu. I saw this link
http://xanthippi.ceid.upatras.gr/people/evangelidis/matlab_opencv/
but its for Windows and I'm not sure where Ubuntu stores opencv. There are a couple places I found opencv folders
usr/local/include/opencv and
usr/local/include/opencv2 and
usr/local/share/OpenCv
Tried these with OCVROOT but got 'Error: Unexpected Matlab Operator'. Not sure what I'm doing wrong here. Any help would be much appreciated.
Thank you!
Mex needs to be told where the OpenCV header files are. You can either fix it in ~/.matlab/R2013a/mexopts.sh or just put a -I argument on the mex command line. You will find the answer to How to link during Matlab's MEX compilation helpful.
You will have to sort out which of those OpenCV versions you want to use. Might be best to install you own so you know what you are dealing with.
'Error: Unexpected Matlab Operator' would be cause by an error in your matlab code.
matlab_opencv should work fine on Linux, the only windows specific thing about it the instructions, as far as I know.
unless you have a custom mexopts.sh, I don't think setting OCVROOT will hve any affect on Matlab.
So like the title says I've been following this tutorial which seems to be the go to tutorial for how to handle haar feature training using the OpenCV.
Mergevec is a utility that merged together vec files so that you could generate a large number of samples from relatively few images. Anyway, he has an exe but it appears to be for 32-bit OpenCV 2.4.3 while I have 64-bit version 2.4.5. Any help would be appreciated!
My version is built using cmake and Visual Studio 10 as the compiler
Figured it out! Hopefully others can make use of this too!
Basically you want to:
First add mergevec.cpp to the folder \opencv\apps\haartraining then add the following to CMakeLists.txt
# -----------------------------------------------------------
# mergevec
# -----------------------------------------------------------
add_executable(opencv_mergevec mergevec.cpp)
set_target_properties(opencv_performance PROPERTIES
DEBUG_POSTFIX "${OPENCV_DEBUG_POSTFIX}"
OUTPUT_NAME "opencv_mergevec")
I am running Python2.7.1 and OpenCV 2.2 without problems in my WinXP laptop and wrote a tracking program that is working without a glitch. But for some strange reason I cannot get the same program to run in any other computer where I tried to install OpenCV and Python (using the same binaries or appropriate 64 bit binaries). In those computers OpenCV seems to be correctly installed (although I have only tested and CaptureFromCamera() in the webcam of the laptop), but CaptureFromFile() return 'None' and give "error: Array should be CvMat or IplImage" after a QueryFrame, for example.
This simple code:
import cv /
videofile = cv.CaptureFromFile('a.avi') /
frame = cv.QueryFrame(videofile) /
print type(videofile) /
print type(frame)
returns:
type 'cv.Capture' /
type 'NoneType'
OpenCV and Python are in the windows PATH...
I have moved the OpenCV site-packages content back and forth to the Pyhton27 Lib\Site-packages folder.
I tried different avi files (just in case it was some CODEC problem). This AVI uses MJPEG encoding (and GSpot reports that ffdshow Video Decoder is used for reading).
Images work fine (I think): the simple convert code:
im = cv.LoadImageM("c:\tests\colormap3.tif")
cv.SaveImage("c:\tests\colormap3-out.png", im)
opens, converts and saves the new image...
I have tested with AVI files in different folders, using "c:\", "c:/", "c:\" and "c://".
I am lost here... Anyone has any idea of what stupid and noob mistake may be the cause of this? Thanks
It may sound stupid, but I just had the same issue with the same symptoms for the same code snippet (Python 2.7.1, Win 7, OpenCV 2.2.0). I changed file path from
capture = cv.CaptureFromFile('C:\Misc\tree.avi')
to
capture = cv.CaptureFromFile('C:/Misc/tree.avi')
and voila
<type 'cv.Capture'>
<type 'cv.iplimage'>
I was having this problem, and here is how I fixed it. I took a look at the output of OpenCV's cmake command, and it had the following line:
...
-- FFMPEG: NO
...
In order to fix this, you might be able to get away with simply installing the following libraries:
sudo apt-get install libavformat-dev libavcodec-dev libavfilter-dev libswscale-dev
Re-running cmake will hopefully now say:
...
-- FFMPEG: YES
...
Re-compile OpenCV, re-install it, and hopefully you can now read videos. If you still have problems, you can try to compile ffmpeg using the --enable-shared option, using these as guides:
http://opencv.willowgarage.com/wiki/FFMPEG
http://ubuntuforums.org/showthread.php?t=786095
Hope that helps.
This must be an issue with the default codecs. OpenCV uses brute force methods to open video files or capture from camera. It goes by trial and error through all sources/codecs/apis it can find in some reasonable order. (at least 1.1 did so).
That means that on n different systems (or days) you may get n different ways of accessing the same video. The order of multiple webcams for instance, is also non-deterministic and may depend on plugging order or butterflies.
Find out what your laptop uses, (re)install that on all the systems and retry.
Also, in the c version, you can look at the capture's properties
look for cvGetCaptureProperty and cvSetCaptureProperty where you might be able to hint to the format.
[EDIT]
Just looked i tup in the docs, these functions are also available in Python. Take a look, it should help.