OpenNI + OpenCV don't work with CV_CAP_OPENNI C++ - opencv

I'm trying to use OpenCV with Kinect on Windows 7 x64, so I installed OpenNI, NITE and PrimeSense (by avin2).
I used CMake to compile the OpenCV 2.3.1, everything is correct with CMake Flags I checked, but I tried to use a simple code and it never found the Kinect.
All the samples of OpenNI and PrimeSense work fine.
I already installed x86 and x64 drivers and it still doesn't work!
I'm using VideoCapture, and isOpened, always returns 0.
Anyone know the solution?

I did that under linux ubuntu 12.04 last week end and that work fine.
Try to re-install componant by componant, and recompile your openCV.
I did that last week end.
But I agree there is things wich are not clear about how deal with that.
I replaced the kinect by an assus xtion and right now that don't work... but this an other topic.
About PrimeSense hardware, as I khnow kinect is made by PrimeSense... moreover PrimeSense is a member of the OpenNI project which is use in background of the libraries P.C.L. , openCV, and on the ros's openni_camera stack...

I have installed the opencv kinect on windows 7-64its (Professional) and works fine.
1.Drivers to kinect: here
Note
When you to install the dirvers make sure that the "Windows update" will not install aditional
drivers.
Tip: Disconnect the internet when you install it. ;)
Check in the "Device Manager" and search for PrimeSense.
Something like this:
PrimeSense
|- Kinect Audio
|- Kinect Camera
|- Kinect Motor
Check if it's working. Run a OpenNI sample.
2.OpenCV
Download it:
...://sourceforge.net/projects/opencvlibrary/files/opencv-win/2.3.1/OpenCV-2.3.1-win-superpack.exe/download
Configure the opencv on cmake. Remeber check to on the "OpenNI" option.
Maybe you'll get an erro like "warning: PrimeSense..." this happen because the OpenCVFindOpenNI.cmake is outdated.
You have to do some changes.
Go to here and download the changes:
Click here and download it (at bottom of page: "Download in other formats: Original Format").
You have to do the changes in the original file "OpenCVFindOpenNI.cmake".
It's in the root folder "OpenCV-2.3.1\"
The line that has "-" you delete and the line tha has "+" you replace/add.
Configure and compile the openCV.
After this it'll works fine, at least it should... :)
Sure.. You have to compile... ;)
I my case - Visual Studio C++ 9(2008) - (I compiled in the Release mode only)
You have to set the "bin" in the patch of system after compile..
Run a sample:
"OpenCV-2.3.1\samples\cpp\kinect_maps.cpp" and enjoy.

kinect for windows perhaps is not supported by Primesenser hardware drivers or even by avin2

Related

OpenCV version compatibility

I'm trying to apply my algorithm (made OpenCV) to the Inspection machine.
but, my develop environment is OpenCV 4.6 (win10). but the machine's env is OpenCV b5a (win XP)
so, we have problem in here.
I know the b5a version is too old.
but We can't the OpenCV version in machine go up. (the soft ware is too heavy to change version)
and the my algorithm include so many OpenCV function. so It is not easy to make without OpenCV function.
Could anyone have a good idea for figure this problem?

How to enable CUDA 5.0 in opencv v2.4.4 and VC10 without CMake and solve error 'missing cudart32_42_9.dll'?

This is my first post, please accept my apologies if I am unclear or fail to completely abide with posting rules. I have in any case sought far and wide in prep for my own question.
Working with:
Windows 7 Enterprise version 6.1.7600
Intel Xeon CPU Quadcore 3.07GHz
NVidia Quadro 4000 GPU
CUDA v5.0 Toolkit for Windows x64 build
OpenCV v2.4.4
OpenCV Cuda Package belonging to opencv v2.4.4
Microsoft Visual Studios C++ 2010 Express ('vc10')
(!) Without CMake (!)
steps, tutorials & checks I've done:
I have installed and configured software I required for opencv 2.4.4 following the opencv.org tutorial....
with vc10, following the opencv.org tutorial on building opencv in vc10 (applying the there-described global method and placing the gpu-related dlls on top), but
I have not installed CMake software and never had any need for it, until I attempted moving calculations to the gpu.
I've furthermore copy-pasted all the .dll files I'm applying in this
vc10-solution into the 'Debug'-folder (placed in the same folder as where
the .sln file of this solution is).
Lastly, I've followed the NVidia developer Zone CUDA 5.0 Getting Started
Guide up to the 'Verify Installation' paragraph, with successful outcome, and also configured the Build configurations to include CUDA compilation following the 'build customization for existing
projects' instructions.
This question is about trying to speed up a win32 console .cpp that I've made in debug-mode (i.e. an visual studios solution using the win32 OpenCV library a rather simple image processing project, but with a blur with a large kernel that's taking much time) by making it run on the gpu. However, I am experiencing trouble running opencv with cuda 5.0 (even though OpenCV Cuda Package's readme.txt tells me to download and install Cuda 5.0).
Upon compiling and running in vc10 (=hitting F5, with Win32 Platform) - or likewise upon running the corresponding .exe executable-, I get an system error saying that "The program could not be started because cudart32_42_9.dll is missing on my computer".
Apparantly , even though opencv's readme tells me to use cuda5.0, it's still looking for the cuda-libraries belonging to 32bits cuda 4.2 toolkit (cudart 32 _42_9.dll) - and obviously not finding them because they're not installed.
In this question it is mentioned that OpenCV v2.4.4 simply hasn't been compiled with cuda 5.0 and the only way to make this run is to compile my own libraries using CMake.
My Question:
I am wondering if in the meantime allowing OpenCV v2.4.4 to run using x64 cuda 5.0 has become possible but WITHOUT having to compile my own libraries using CMake.
I would kindly like to ask any of you to share with me precisely what steps to take. In your solution, please write in detail, as this is only my third week of using C++ language, compilers libraries dlls and all such.
Many thanks in advance!
EDIT
This question has actually now (due to #talonmies 's comment) become much more like a question asked by
user 'duttasankha' titled 'OpenCV with cuda MS Visual Studio 2008', and
user 'zebullon' titled 'Do I need a 64 bit SDK on a 64 bit machine'.
In order to fully answer my own question:
I have been able to get CUDA 5.0 running without having to compile anything myself (e.g. without having to use CMake) or reinstalling any GPU driver software.
I followed - amongst others – duttasankha and zebullon’s posts (I named these in the EDIT in my question) and took an extra, small leap of faith.
I downloaded the 32 bits CUDA 4.2 SDK (software development kit, available on the same site as the other CUDA downloads) and
installed/extracted it. This is noteworthy because I had a newer
CUDA Toolkit and driver version (5.0) installed, which was 64bits!
I looked (windows search function) for where the SDK files had been
extracted and found cudart32_42_9.dll in the C:...\My
Documents\NVIDIA GPU Computing SDK 4.2\C\common\bin folder.
I copied all of the 32bits dll's in this folder (all the dll's
whose names end on '32_42_9.dll') and placed them (together with
the opencv-dll's I mention in the summary in my question above) in
the folder named 'Debug' which is positioned in the same folder in
which the .sln solution-file of this project is (this is the folder
where Visual Studios always places the .exe executable files
belonging to the project). I copied all of them because even though
I only got the message that this one cudart-dll was missing, the gpu
functions in opencv need all of the copied dll’s.
I had already completed the directions concerning the required
Visual Studios settings. (see opencv.org tutorial on enabling Visual
Studios 2010, doing so the global (not local) way, also see this
guide.
But now, in the Linker; Input; Additional Dependancies field I completed my
dependencies list with the cuda-related libraries. It looked like
this: C:\opencv\build\x86\vc10\lib\opencv_gpu244d.lib
C:\opencv\build\x86\vc10\lib\opencv_core244d.lib
C:\opencv\build\x86\vc10\lib\opencv_highgui244d.lib
C:\opencv\build\x86\vc10\lib\opencv_video244d.lib
C:\opencv\build\x86\vc10\lib\opencv_ml244d.lib
C:\opencv\build\x86\vc10\lib\opencv_legacy244d.lib
C:\opencv\build\x86\vc10\lib\opencv_imgproc244d.lib Notice that the cuda-related lib’s 'opencv_gpu244d.lib' and 'opencv_core244d.lib' are at
the top of this list. (Incidently, this core244d.lib is
cuda-related, because this is the opencv core library that came from
the OpenCV-2.4.4-CUDA-vc10.7z package I downloaded from
Sourceforge.com . Instructions for unpacking/ correct placement are
available in the accompanying .text-file in this 7z package from
Sourceforge).
In Visual Studios , in the Project-Folder Explorer, I rightclicked on
the name of my project (=vc10 solution) and choose
Build-configuration. Here I placed a check in the CUDA 5.0(.targets,
.props) which showed corresponding path “
$(VCTargetsPath)\BuildCustomizations\CUDA 5.0.targets “.
Now, running my code does not prompt any more system errors concerning missing DLL’s and the CUDA ‘Initialization and Information ‘ functions from the opencv.org documentation are also functioning in a new test-project I made up to check global functioning of the CUDA set-up.
Apparantly, the Driver and CUDA Toolkit of a newer version know how to cooperate with the DLL of the older version CUDA SDK.
Hope someone else will save some time when they read this. If I missed details in my description of the answer, please let me know.

How to setup OpenNI 2.0 with OpenCV for a Kinect project?

I am working on my final year project. I need to work with Kinect to detect hand movements. I have tried a few ways and got some results, however, none was enough to meet the needs of the project. I saw this video long ago, and just got to know that they open sourced it recently. So I gave it a try.
My problem now is how to set things up.
The above awesome project uses OpenNI with Kinect. I tried to follow OpenCV tutorials to build it from source code, to let OpenCV work with OpenNI.
Problems:
It says "For the OpenNI Framework you need to install both the development build and the PrimeSensor Module." but as I followed the links some of them were dead. Seems like OpenNI 2.0 doesn't use PrimeSensor any longer.
It also says that in Cmake folders, one is OpenCV/Src, the other is /build. But the OpenCV I downloaded doesn't have anything as Src folder.
Still I used the whole folder as Src, and built it to a build folder and checked WITH OPENNI. I used the Include and Lib folder in OpenNI2 I downloaded, but when I built the OpenCV solution (already generated from CMake) all builds failed.
Also, while generating with Cmake, even if my future OpenCV solution had been successfully built (which wasn't the case), Cmake would have kept telling me how PrimeSense was not available, which made me feel so insecure. :(
I am a bit confused about 32- and 64-bit. The above project I want to follow says it works on 64-bit. But I use MS C++ Express, all projects are 32-bit. So which PrimeSense drivers (given in OpenNI2) should I use?
Could anyone please tell me how to set all these things (OpenNI2.0, OpenCV 2.4.3, PrimeSense) together so I can work with Kinect?
A while back I wrote two tutorials on 1) how to set up OpenNI 1.5 with NITE 2) How to compile OpenCV with OpenNI support.
These can be found here and here
I know this is not what you asked for, but the process of compiling OpenCV with OpenNI 2.0 should be similar and might help you understand where you are going wrong.
I will try to write a newer tutorial, however since I currently do not have access to a sensor, I might not be able to test if it works out in the end.
EDIT:
I have written some code to access Kinect data streams in OpenCV Mat format using OpenNI 2.x. The code github repo can be found here. Detailed guidance on how to set everything up can be found here.
OpenNI 2.x is much advanced than the previous versions. You don't need to install primesense sensorkinect driver. You can use OpenNI 2.x along with the Microsoft Kinect SDK 1.x.
Install both 64 and 32-bit OpenNI 2.x if you have Windows 7 x64 otherwise only 32-bit. Configure it with Visual Studio 2010 or 12. You can follow this video:
http://www.youtube.com/watch?v=ACqPsV0R4to
Then configure OpenCV for visual Studio 2010 or 12. You can follow this link:
http://4someonehelp.blogspot.in/2013/04/install-opencv-245-using-visual-studio.html
Thanks

OpenCV does not open videos on other computers

I have the x64 project that works perfectly fine on my Windows 7 machine whether I run deployed version or in the Visual Studio 10. Now, I got a hand on 4 other machines with x64 Windows 7 platforms and tried to install on them, however those ones work fine except the bit of code which has to capture video always fail to load.
That bit is a typical openCV video capture bit:
cap = VideoCapture(file);
if (!cap.isOpened ())
{
cerr << "I have failed!" << endl;
return 0;
}
The file variable is generated when user chooses the file to load using file dialog it works perfectly fine on all machines if the file is, for instance, a picture, therefore that's not the reason.
Maybe the produced installer does not contain the necessary library or something like that. I really have no idea.
Cheers,
Vilius
Ok, As I suspected some libraries were missing in the installer package, I managed to load video files once I copied compiled OpenCV to another computer and added the path to find it.
Since many people had problems loading videos when ffmpeg was not configured, I added this library manually to the deployed software and it fixed the problem. Therefore, the problem was that Visual Studio was not adding opencv_ffmpeg241_64.dll library to the installer.
Cheers,
Vilius
If the installer packed everything correctly, you still have to take care of the codecs yourself.
Try to install a codec pack (K-Lite Codec Pack or something else) on those machines.
On the other machines, have you configured OpenCV with the ffmpeg option while installing it? Check the Cmake configuration list and print it out here if possible.
Also, it wouldn't hurt to check if you have the respective camera drivers installed correctly for those computers if you are capturing frames directly instead of from a file.

OpenCV 2.4 VideoCapture gets no input from webcam when launched standalone

I am using OpenCV 2.4 in my project to process the images from webcam. Everything works fine in Visual Studio 2010 (both release and debug builds), but when I try to launch exes directly from explorer, the app does not the get input. The camera is started however - it's control LED is on.
Does someone know how to make it work standalone?
I have found something relevant here:
http://rafaelbarreto.com/2011/06/05/opencv-2-2-webcam-windows-not-working/
and here:
Can't access webcam with OpenCV
I tried to follow the steps, building OpenCV 2.4 with these prepocessor definitions, but it did not solve my problem.
Thanks
Solved. The problem was, that Visual Studio linked shader sources from somewhere else than during the exectution through IDE.
If the same happens to you, be sure to check it at least four times (I checked 3x).

Resources