opencv - unable to capture frame from camera on raspberry pi - opencv

My pi camera is connected and enabled, raspistill takes photos successfully. In python, cv2.VideoCapture(-1).read() always returns (False, None). I'm stumped.

OpenCV relies on the V4L2 (Video for Linux) module, so try adding the following line at the bottom of the file /etc/modules and rebooting your Raspberry Pi.
bcm2835-v4l2
Mine now looks like this in toto:
# /etc/modules: kernel modules to load at boot time.
#
# This file contains the names of kernel modules that should be loaded
# at boot time, one per line. Lines beginning with "#" are ignored.
bcm2835-v4l2
This ensures that the Broadcom Video For Linux 2 (v4l2) driver is loaded at all subsequent reboots.

Related

Trying to port application to docker nanoserver container. Running exe fails with exit code -1073741515 (Dependency missing)

I'm currently trying to port my image optimizer application to a NanoServer docker image. One of the tools my image optimizer uses is truepng.exe. (Can be downloaded here: http://x128.ho.ua/clicks/clicks.php?uri=TruePNG_0625.zip)
I simply created a nanoserver container and mounted a folder that contained truepng.exe:
docker run --rm -it -v C:\data:C:\data mcr.microsoft.com/windows/nanoserver:2004-amd64
When I now run truepng.exe I expect some output regarding command line arguments missing:
C:\MyLocalWindowsMachine>truepng
TruePNG 0.6.2.5 : PNG Optimizer
by x128 (2010-2017)
x128#ua.fm
...
However when I call this from inside the nanoserver docker container I basically see no output:
C:\data>truepng
C:\data>echo %ERRORLEVEL%
-1073741515
As you can see above, the exit code is set to -1073741515. According to this it typically means that there's a dependency missing.
I then downloaded https://github.com/lucasg/Dependencies to see the dependencies of truepng:
It seems it has some dependencies on 5 DLL's. Looking these up I found that there's apparently something called 'Reverse Forwarders': https://cloudblogs.microsoft.com/windowsserver/2015/11/16/moving-to-nano-server-the-new-deployment-option-in-windows-server-2016/
According to the following post though they should already be included in nanoserver: https://social.technet.microsoft.com/Forums/en-US/5b36a6d3-84c9-4940-8b7a-9e2a38468291/reverse-forwarders-package-in-tp5?forum=NanoServer
After all this investigation I've also been playing around with manually copying over the DLL's from my local machine (system32) to the docker machine without any success (it just kept breaking other things like the copy command which required me to recreate the container). Next to that I've also copied the files from SysWOW64, but this didn't help either.
I'm currently quite stranded on how to proceed further as I'm not even sure if the tool is missing dependencies or if something else is going on. Is there a way to investigate what DLL's are missing once a tool is starting?
Kind regards,
Devedse
Edit 1: Idea from #CherryDT
I tried running gflags (https://social.msdn.microsoft.com/Forums/en-US/f004a7e5-9024-4555-9ada-e692fbc3160d/how-to-start-quotloader-snapsquot?forum=vcgeneral) which gave the following output:
C:\data>"C:\data\gflags.exe" /i TruePNG.exe +sls
Current Registry Settings for TruePNG.exe executable are: 00000000
After this I tried running Dbgview.exe, this however never resulted in a log file being written:
C:\data>"C:\data\DebugView\Dbgview.exe" /v /l debugview-log.txt /g /n
C:\data>
I also started TruePNG.exe again, but again, no log file was written.
I tried querying the EventLogs using a dotnet core application, but this resulted in the following exception:
Unhandled exception. System.InvalidOperationException: Cannot open log Application on computer '.'. This function is not supported on this system.
at System.Diagnostics.EventLogInternal.OpenForRead(String currentMachineName)
at System.Diagnostics.EventLogInternal.GetEntryAtNoThrow(Int32 index)
at System.Diagnostics.EventLogEntryCollection.GetEntryAtNoThrow(Int32 index)
at System.Diagnostics.EventLogEntryCollection.EntriesEnumerator.MoveNext()
at EventLogReaderTest.ConsoleApp.Program.Main(String[] args) in C:\data\EventLogReaderTest.ConsoleApp\Program.cs:line 22
Windows Nano Server is tiny and only supports 64-bit applications, tools, and agents. The missing dependency in this case is the entire x86 emulation layer (WoW64), as TruePNG is a 32-bit application.
Windows Server Core contains WoW64 and other components missing from Nano Server. Use a Windows Server Core image instead.
Example command:
docker run --rm -it -v C:\Temp:C:\Temp mcr.microsoft.com/windows/servercore:2004 C:\Temp\TruePNG.exe
Yields the expected output:
TruePNG 0.6.2.5 : PNG Optimizer
by x128 (2010-2017)
x128#ua.fm
TruePNG {options} files
options:
/f# PNG delta filters 0=None, 1=Sub, 2=Up, 3=Average, 4=Paeth, 5=Mixed
/fe PNG extra filters, overrides /f switch
/i# PNG interlace method 0=None, 1=Adam7 (default input)
/g# PNG gamma 0=Remove, 1=Apply & Remove, 2=Keep (default)
[...]

Commands for reading, loading and unloading drivers on BeagleBone Black?

I am using a BeagleBone Black with Xenomai and RTnet on top. As some real-time programs are not working it could be that the installed drivers on my BeagleBone Black are still the standard drivers and not the real-time drivers.
As I did not find anything on internet (only how to install drivers for Windows when using BeagleBone Black) I would like to ask you if anybody knows a command for BeagleBone Black to read, load and unload installed drivers on BBB?
I have found the commands for read, load and unload driver/modules. See the following output of the command window: the commands are lsmod for reading, insmod for loading and rmmod for unloading.
# lsmod
Module Size Used by Tainted: G
rtipv4 18699 0
rtpacket 4179 0
rt_ticpsw 26115 0
rt_davinci_mdio 4570 0
rt_smsc 2165 0
rtnet 28479 3 rtipv4,rtpacket,rt_ticpsw
omap_rng 4174 0
# insmod
BusyBox v1.22.1 (2019-03-16 12:39:06 CET) multi-call binary.
Usage: insmod FILE [SYMBOL=VALUE]...
Load the specified kernel modules into the kernel
# rmmod
BusyBox v1.22.1 (2019-03-16 12:39:06 CET) multi-call binary.
Usage: rmmod [-wfa] [MODULE]...
Unload kernel modules
-w Wait until the module is no longer used
-f Force unload
-a Remove all unused modules (recursively)
#

VIDEOIO ERROR: V4L: can't find camera device

I am using ubuntu16.04 and trying to run opencv script.
when i use:
video_capture = cv2.VideoCapture(-1)
it gives me error VIDEOIO ERROR: V4L: can't find camera device
No video window opens
But when i run
video_capture = cv2.VideoCapture('test.jpg')
It opens window shows the picture and close the window.
Please tell me why it is not streaming video directly from camera.
The suggestion api55 gave in his comment
video_capture = cv2.VideoCapture(0)
is what I would try first.
Generally, you can list the available cameras with ls /dev/video* or v4l2-ctl --list-devices. Here sample output:
NZXT-U:rt-trx> v4l2-ctl --list-devices
Microsoft® LifeCam Cinema(TM): (usb-0000:00:14.0-1):
/dev/video1
Microsoft® LifeCam Cinema(TM): (usb-0000:00:1a.0-1.3):
/dev/video0
/dev/video0 corresponds to device id 0, etc.
PS: v4l2-ctl is quite useful for solving camera issues and can do much more than --list-devices. I installed it via packagev4l-utils on a 16.04 machine.
Late, but to get mine working i put in terminal:
-ltrh /dev/video*
To get a list of the video devices that are plugged into my computer. Then for each one I did:
sudo chmod 777 /dev/videox
Where x was one of the video files that were listed, giving everything access to them. Probaly not the most secure solution, but it got my code working.

Cannot connect xtion pro live with Ubuntu 12.04

I need to work with asus xtion pro live to detect hand movements and objects. I am an amateur as far as it concerns programming this camera.
My problem is how to connect them and from where to start.
I work on Ubuntu 12.04. I've downloaded Ros fuerte and both Openni2 and OpenCV. When i plug the camera (usb port) and run the lsusb command, i see this:
"Bus 001 Device 003: ID 1d27:0601 "
Even when i run the command $ roslaunch openni_launch openni.launch
i get:
[ INFO] [1415717730.873978521]: No matching device found.... waiting for devices. Reason: openni_wrapper::OpenNIDevice::OpenNIDevice(xn::Context&, const xn::NodeInfo&, const xn::NodeInfo&, const xn::NodeInfo&, const xn::NodeInfo&) # /tmp/buildd/ros-fuerte-openni-camera-1.8.6/debian/ros-fuerte-openni-camera/opt/ros/fuerte/stacks/openni_camera/src/openni_device.cpp # 61 : creating depth generator failed. Reason: USB interface is not supported!
Can anyone please help? Is there a problem with the camera driver?
Thank you in advance.
you must go to a terminal and do
sudo nano /etc/openni/GlobalDefaults.ini
and there find UsbInterface and make sure it is not a comment (without ; at the beginning) and that is equal to 2
UsbInterface=2
I heard that this may give you problems with Kinect hardware (the same error you are getting now). But, if you use the Kinect later on and gives this problem, just comment it and it should work
;UsbInterface=2
You must reboot every time you change this value!!
I hope this works for you ;)

How to run a mindtct package (NBIS software)for a entire database(a set of 100 images) at a time in Redhat Linux

I have installed NBIS software in Redhat Linux in VMware and running as a host OS in my windows 7 system.
Till now I executed giving only one image, but now I need to run the entire DB with 100 images at a time and I should get the extracted minutiae.
I use the below cmd:
/NBIS/src/bin/mindtct /NBIS/Test_4.1.0/mindtct/data/5_2.jpg
/NBIS/output/5_2.xyt
Can anyone resolve my issue? What cmd should I use?
You can write a script to loop over all the images in your collection, or better yet, write a C program to wrap the mindtct functions, doing whatever you want to do within your new app. Take a look at the source for the binary mindtct in NBIS, especially the get_minutiae() function.
In the folder with your images you can use a bash script. This is the relevant part from mine. A simple for loop that will convert all images with the extension jp2 to xyt images.
PHOTOTYPE="*.jp2"
SAVEPATH="path/to/save/folder/"
for PIC in $PHOTOTYPE
do
echo "Processing mindtct -m1 $PIC $SAVEPATH/$PIC"
mindtct -m1 "$PIC" "$SAVEPATH/$PIC"
done
I tried it on Raspbian to Raspberry Pi
./mindtct path/file.jpg path/output
and it produced 8 files:
.brw, .dm, .hcm, .lcm, .lfm, .min, .qm, .xyt
In my understanding you should use a mindtct function to compare two finger images.

Resources