OpenCV 2.4.6 crash at program runtime - opencv

I have compiled OpenCV 2.4.6 on my Raspberry Pi using the Sourceforge repository. I used the following commands to install it:
wget http://downloads.sourceforge.net/project/opencvlibrary/opencv-unix/2.4.6/opencv-2.4.6.tar.gz
tar zxvf opencv-2.4.6.tar.gz
cd opencv-2.4.6
cmake -DCMAKE_BUILD_TYPE=RELEASE -DCMAKE_INSTALL_PREFIX=/usr/local -DBUILD_PERF_TESTS=OFF -DBUILD_opencv_gpu=OFF -DBUILD_opencv_ocl=OFF
make install
I get no errors when I compile. I am using the Face Recognition API to recognize faces from video captured through the Raspberry Pi camera module. I am using a C++ API called RaspiCam to capture frames from the camera, and it is compatible with OpenCV, allowing you to save captured frames as an OpenCV Mat object. The documentation for the API is at http://www.uco.es/investiga/grupos/ava/node/40. The source code for building the RaspiCam library is http://sourceforge.net/projects/raspicam/files/?source=navba.
Most of the time when I run my face recognition application, it runs fine. But every now and then, when I run my app it becomes unresponsive after an unpredictable amount of time with no error. Task Manager shows that the program is still running, but at a very small CPU usage like 2% instead of the usual 70-80% that it normally uses. I placed OpenCV try blocks for error handling to catch any OpenCV errors that may arrive, but none of them get invoked. I have noticed that my program crashes less often when I don't use the OpenCV highgui window to display frames, particularly if I run it through ssh. Has anyone had any similar problems?

I was experiencing the same problem with 'raspicam-0.1.1'. For me, downgrading the raspberry pi firmware resolved the problem.
sudo rpi-update 8660fe5152f6353dec61422808835dbcb49fc8b2
I found this firmware version mentioned when I was browsing the RPi-Cam-Web-Interface

Related

Unable to run cameras under Opencv 4.1.2 and MacOS Catalina

I am unable to open a camera on the network using Catalina, Python 3.7 and OpenCV 4.1.2.
I am running an IP Webcam app on a phone that exposes an endpoint as: http://192.168.87.26:8080/video. The following command fails:
import cv2
cap = cv2.VideoCapture('http://192.168.87.26:8080/video')
and the error message is:
OpenCV: Couldn't read video stream from file "http://192.168.87.26:8080/video"
At the same time, a video mp4 file works well. I have added permissions in MacOS such that the default webcam also works.
I have tried with both the pip install opencv-python as well as built an opencv from source, but the error for the video stream does not go away.
FFMPEG is installed in the system. FFPLAY on this URL http://192.168.87.26:8080/video works very well.
$ brew info ffmpeg
ffmpeg: stable 4.2.1 (bottled), HEAD
Play, record, convert, and stream audio and video
https://ffmpeg.org/
/usr/local/Cellar/ffmpeg/4.2.1_2 (287 files, 56.6MB) *
What I am missing?
After some more digging around, I was able to make it work. Looks like I had an old version of Intel OpenVINO around from Mojave days that was interfering with any local version of OpenCV that I would install.
During the exercise, I also figured that building OpenCV from scratch is far better than installing it from pip.

converting OpenCV not working with Python-for-android

I have a pretty solidly-functioning Kivy app, written in python and using the OpenCV2 library. having gotten it working on my laptop (windows) I then tried to convert it into an android APK using the python-for-android VM. after some issues (including adding more space to the VM and installing OpenCV on it) I managed to compile the APK successfully.
however, when running the app on android, the opencv part doesn't seem to be working. the kivy menus and such work fine, but loading the video - the job that opencv handles - simply doesn't happen. I'm going to try and connect the android device to the VM directly in order to try and get some debug information, but for now, can anyone think of any reasons why I might be having these issues?
thanks.

BeagleBone, OpenCV and webcam issue

I've been trying to get BeagleBone work with OpenCV and a capture camera, but I couldn't manage to do it so far. I use Logitech C270 webcam. Here is what I did so far:
I installed OpenCV binaries and tried my camera. Capture didn't work. I downloaded the latest version from Git and compiled it. Then it worked on my desktop.
Since Ångström have pre-installed OpenCV, I directly tried to connect the webcam. But I had "select timeout" errors and when I saved the captured image, it was all black.
I deleted OpenCV from Ångström (opkg remove opencv and opencv-dev). It said it worked, but libraries were still in /usr. So I deleted them manually and copied libraries that I cross-compiled in my host. But now, I cannot even connect to camera. Capture returns null again.
I checked opkg list-installed, still OpenCV 2.4 is listed there. However, libraries in /usr/lib and include are the ones that I copied. How can I fix this problem?
Note: Webcam is recognized by Ångström, and dmesg shows successful connection to the webcam.
It seems something was wrong on installation of Linux itself. I re-compiled the latest Ångström and installed it to BeagleBone. Everything worked fine as it should. It seems sometimes it's better to take the hard way.

EmguCV - nvcuda.dll could not be found

I've been asked to build a real-time face recognition application, and after some looking around I've decided to try EmguCV and OpenCV as the facial recognition library.
The issue I'm having at the moment is trying to get the SDK installed and working. I've followed the instructions found here to try and get it running, but I still can't run the samples. Whenever I try and run them, I get the error
The program can't start because nvcuda.dll is missing from your computer.
Try reinstalling the program to fix this problem.
I've tried most of the usual fixes, such as adding the bin folder to my environment path and copying the dll's into my system32 folder, but none of it seems to work.
EmguCV version 2.4.2.1777-windows-x64-gpu
Windows 8
AMD Radeon HD 6700 series graphics card.
I'm assuming this is an issue with the fact that I dont have an nVidia graphics card, but I'm not sure what I can do about it. For now, I'm going to try recompiling the source rather than using the downloaded .exe, and seeing if that helps.
Any suggestions?
Had the same problem, EmguCV 2.4.2 (no matter if x86 or x64) is compiled with GPU and you have to had nvidia GPU with CUDA support. So, if you want for eg. Fisherfaces from 2.4 in C# - wait for non-GPU release or buy/borrow CUDA card ;)
I happen to have the exact same problem as you. Everything is working fine on my computer (WinXP 32-bit) but not on Win7 64-bit computers.
This was because on my computer I already have OpenCV 2.4.2 installed and when I execute my program the path to the OpenCV dll points to the OpenCV folder and not to the dlls in the EmguCV folder. The original OpenCV dll don't have this dependency on NVidia's driver.
I used Dependency Walker to help me find out what was happening, as suggested here.
This link says that only the -gpu packages have gpu processing enabled but as you say the latest version (2.4.2) only a gpu package and no no-gpu package...
I read here that all I needed was to download the latest NVidia drivers to get the nvcuda.dll file but I downloaded many packages and never found this file: gpu computing sdk, cuda toolkit, display drivers, device drivers...
My workaround, instead of using an older version of EmguCV/OpenCV is to use the original dll from OpenCV 2.4.2.
I just used nvcuda.dll from dll-files.com.
It seems the issue is that the latest version on the site does not contain a non-GPU enhanced download, and that the GPU enhanced download requires an nVidia graphics card for CUDA integration.
I successfully downloaded and run the previous version which does not have GPU enhancements.
I had similar problem.
When I compile and run my application on computer with NVIDIA gpu it works fine.
Problem was when I moved app to another computer.
This second computer has no NVIDIA gpu and it threw 'Emgu.CV.CvInvoke' exception.
After many attempts I fortunately solved this problem.
As you mentioned before for now there is only gpu package for version 2.4.2.
I didn't notice this before.
For me solution was:
Copy files: 'cudart64_42_9.dll' and 'npp_42_9.dll' into Debug (application) folder
Copy file 'nvcuda.dll' into System32 folder.
After this steps aplication works on all computers even without NVIDIA gpu/ CUDA.
Other solution might be using opencv universal gpu version (for now is alpha 2.4.9) link: http://sourceforge.net/projects/emgucv/files/emgucv/2.4.9-alpha/
You can download source EmguCV from GIT and compile it, i have done this and works :
http://www.emgu.com/wiki/index.php/Download_And_Installation#Building_from_Git
It generates a non-GPU version of dlls
Regards.
here's also another copy of the dll's:
http://www.kimchiandchips.com/files/vvvv/nvcuda/
so 2 solutions:
Get NVidia CUDA DLL's from the above link. Ideally rename the 64 or 32bit version to nvcuda.dll based on your required platform. Put next to your opencv dll's
Upgrade to 2.4.9 which has universal GPU support
I also had some problems when doing my dissertation using EmguCV for face recognition.
Try to use the stablest version libemgucv-windows-x86-2.4.0.1717.exe
Try not to use the gpu download, this version has the least bugs and the 32-bit is better than the x64.
when compiling for the first time use visual studio 2012.
With this version you wont need to install all the above mentioned. You can see this example to know it really works : http://sourceforge.net/projects/emgufacerecog/

Getting webcam to work in OpenCV 2.3 with Cygwin

I have a problem trying to get a webcam in OpenCV 2.3 to work with Cygwin. I have a Windows 7 64-bit system and I use Notepad++ and cygwin compilers to do my C++ programming. I have seen other posts with similar problems:
Getting Webcam to work in OpenCV
Can't access webcam with OpenCV
I first tried installing OpenCV via the Cygwin Ports. This is rather easy to install, but alas I run into the webcam problem (always returns false when trying to find a device). I have also attempted to build OpenCV and install manually using the command line flavor of CMake. I tried adding the HAVE_VIDEOINPUT and HAVE_DSHOW flags, but no dice. All my programs compile nicely and I have all the functionality of OpenCV aside for this webcam thing.
Has anyone successfully built OpenCV 2.3 on Cygwin with webcam working?
It is unlikely that cygwin build of OpenCV will be able to access a webcam. At least it is not possible without hacking OpenCV cmake scripts. Under cygwin OpenCV build always follows the UNIX branch and videoinput/directshow is excluded from build.

Resources