Using imshow in opencv without running X - opencv

I've got an application with a Raspberry Pi running Debian that is pretty performance demanding and I am trying to avoid starting X when booting and jumping directly into the program. This works fine, but if I would like to use the 'imshow' function in OpenCV, it does not work correctly, instead it says 'GTK-Warning: cannot open display" and exits the program.
Is it feasible to display a fullscreen image/video capture with opencv using imshow or any other function without X, or is it entirely dependent on the X?
Thanks,
For clarification, there is a monitor, it just shows the terminal prompt instead of a desktop. So the raspberry pi is getting an image to a screen at the correct resolution, I guess what I don't understand is what X11 does for opencv as far as handling of the window/image? I imagine a lot that cant be easily replicated.
But maybe a lightweight X11 alternative would be the best way to go if there's not another option, thanks for the tip.

Well, obviously the video output has to go somewhere... You could try Xvfb as a lightweight alternative to a full X11 instance.

Related

How to save a v4l2 buffer image using OpenCV 4.2

I'm using a Raspberry Pi 3B+ with an equivalent board to the Auvidea B101 which is a HDMI to MIPI bridge. The board works correctly and I can save images using the code from my gist ( https://gist.github.com/danriches/80fadc21b5f1b0ca8ba725a8dd598710 ). However when I try to use OpenCV 4.2.0 (compiled locally and samples all work!) I get a segfault as detailed in the comments section of the gist. I can't for the life of me work out why though. If someone has a B101 or equivalent that uses the TC358743 chipset and has it working with OpenCV I'd be greatly appreciative if you have any advice or suggestions.
This all needs to work as fast as possible so apps calling apps is no good, I need to process the buffer and write it to a gstreamer pipe eventually. In fact if I could take the jpeg I get out the original code at line 832 and pass it to an instance of gst-rtsp-server then I'd be a happy man.
Any takers??
Dan

Teensy + IR camera + OpenCV

I have never ever asked this kind of question on StackOverflow before, and I wonder if you could help me guys because it is a "bit" vague.
I have to design a project that uses Teensy (simple ARM platform) for getting data from IR camera (Flir, resolution 80x60) over SPI, and streaming these data to Linux/Windows running machine (through USB-serial) and doing something simple with OpenCV.
THE PROBLEM: The project lacks some "inovation". It should not be something very complicated, but rather different approach, or trying something new.
Do you have recommendations/tutorials/books/experience with working with above mentioned things? OR do you see a potential for teying something new?
You might want to check out the OpenCV Cookbook for some ideas.
There is a project using this FLIR with a Teensy. It provides a thermal image using a small LCD screen (without any aditional computer).
https://hackaday.io/project/8994-diy-thermocam
So, the teensy can get data through spi.
Can the teensy send data through usb then ? Probably but you will have to check if the rate is high enough
.
Using OpenCV directly on teensy is not possible because of size of library. But you can probably make some basic image processing if the code is small enough.
The FLIR Lepton can be directly interfaced with Linux or Windows computer, so I don't really see the use of Teensy.
I would recommend a Raspberry Pi to interface the FLIR Lepton and then do some image processing. It's well documented on the web.

OpenCV: black image captured from usb camera

I am trying to capture an image frame from a USB camera using opencv. However I am always getting a black frame. I have read many posts with this issue and tried all the suggestions but nothing worked for me.
I started using the code discussed here:
http://opencv-users.1802565.n2.nabble.com/Using-USB-Camera-td6786148.html
I have tried including the method cvWaitKey(1000) after many 'critical' sentences. As you can see the waiting value is very high (1000).
I have also tried to save the image frame and, equally, it is a black image.
I am using the following system:
OpenCV 2.2.0
Windows 7, 32 bits
Visual Studio 2010 (C++)
a board usb camera (which I do not know the manufacturer)
The usb camera works well with AMCAP.EXE 1.00.
Could it be because of the camera drivers being used by Windows? Could I change to other drivers that work better for OpenCV 2.2.0?
Thanks
Ok. As I promised to your request in the comments, and sorry to keep you waiting, really been busy. Barely had time to post this answer too. But here it is:
This is me simulating that opencv is capturing black image. On the output window, which I had asked you in the comments about what it says, shows that there is an error.
After investigating, I realised that it is due to the camera's available format:
Of cuz, this is a lousier camera. If you have a better camera like the logitech one, you can see that the format available is so much more.
There are lots of methods, you can try some thing like
capture.set(CV_CAP_PROP_FRAME_WIDTH , 640);
capture.set(CV_CAP_PROP_FRAME_HEIGHT , 480);
capture.set (CV_CAP_PROP_FOURCC, CV_FOURCC('B', 'G', 'R', '3'));//diff from mine, using as example
then the webcam will be able to snap. This webcam is bit faulty, hence the image snapped is not that beautiful.
Hope this is your problem. but it may not be the case too. I like debugging problems, but I can't put down all the possible causes that this happen for you as I am really busy, as you asked for an example, this is one of them. Cheers. If you could tell me what you output window error says, I probably can help more.
EDIT(to answer more in your comments):
Ok, I want you to try a few things:
1)First, instead of using cvQueryFrame, or similar capturing methods, I want you to try use that webcam to capture a video instead. Wait up to maybe say 10 secs to see if it's successful. Reason being, some cameras(lower quality ones) take quite a while to warm up and the first few frames they capture may be an empty one.
2) If the step one doesn't work, try typing
cout << cv::getBuildInformation() << endl;
and paste the results for media I/O and Video I/O? I want to see the results. I would suspect your library dependencies too, but since you said it works with a logitech camera, I doubt that's the case. Of course, there's always a chance it's due to that the camera is not compatible to OpenCV. Does the camera have any brands by the way?
3) Alternatively, just search for usb drivers online and install it, I had a friend who did this for a similar problem, but not sure the process of that.
The first thing, I would suggest is, visit this link and check your camera is working or not
http://www.youronlinemirror.com/
if yes, then go through below link to get started with things, you ll also find a good opencv c++ code out there, the code which you are using is of opencv1 api's c code, I would rather encourage you to go for c++ than the old version of opencv.
http://opencv-srf.blogspot.in/2011/09/capturing-images-videos.html
if you want an answer for your code, then, its simple, as you are saying its giving a black screen, which happened in my case when i started things out with opencv,
it isnt able to take the data from device, so, try this, it might work, as it did for me.
add
cvQueryFrame( capture );
before
IplImage* frame = cvQueryFrame( capture );
I went through the same problem as yours. Then I just changed the version from 3.1.0 to 2.4.13, then my webcam works! No more black images. I guess the 3 version is not compatible with the vs15. Thinking you may have already solved the problem long ago. But just post to let others know if they happen to have the same issue.
Even I faced the same black screen problem while running OpenCV-related programs. So instead of using USB cam I used mobile camera which worked perfectly fine. Use Google apps such as DroidCam (install DroidCam on mobile as well as on laptop/PC) to connect your mobile camera to laptop through Wi-Fi.

can i use an eye detecting opencv code on microcontroller?

i want to do a project which uses eye tracking, is it possible to port an open cv code on a microcontroller.
i am new to opencv as well as microcontroller so can any one tell me if it is possible to make a code which works like this vedio.
http://www.youtube.com/watch?feature=endscreen&v=eBtpKAja-m0&NR=1
Q: Can i use an eye detecting opencv code on microcontroller?
A: Yes, you can
Q: Is it possible to port an open cv code on a microcontroller
A: OpenCV is already in the Unix and Android platform. The easiest approach therefore will be to get hold of some embedded device with ARM. There are a lot of help available for the 'OpenCV-ARM' combination.
Beagleboard and RasberryPi are the cheapest embedded ARM devices available for less than $150. Sometimes they come preloaded with Unix boot system and opencv2.0. Thus it would be so easy to run the executable that you created in the computer system.
Be aware of the speed of the processor. If your algorithm is computationally intensive then you wont be quiet satisfied with the output being obtained in the low-end embedded devices.
If some ARM embedded Linux board can fit into your definition of microcontroller, then there is nothing to port.
http://www.google.com/search?q=opencv+arm

Can I use openCL in a application that I distribute to non developer machine?

I recently started to learn how to use openCL to speed up some part of my code. So far the speed gain is impressive. In one case the code ran up to 50X faster than on the CPU. However I wonder if can start using this code in a production environnement. The reason is that the first time that I tried to run the example code, nothing worked. I was able to make it run by downloading the driver on the Nvidia openCL SDK download page (I have a Geforce GTX260). It gave me a blue during installation but after that I was able to run the example program and create my own code.
Does the fact that it didn't work "out of the box" for me mean that the mainstream drivers does not yet support it, despite the fact that it is specifically written that it does on the driver download page? What about ATI support? Will everyone have to download the special driver that gave me a blue screen on install?
In short, is openCL ready for production code?
If someone can give me some details, I'd like to know. Does anyone has been able to run a simple program on a number of different device without installing anything SDK related?
You may find an accurate answer on the OpenCL forums on the Khronos Group message boards. The OpenCL work group hangs out there regularly.
Does anyone has been able to run a
simple program on a number of
different device without installing
anything SDK related?
Nop. For instance, on ATI's GPUs end-users need to install ATI Stream SDK in order to run OpenCL code (just having an up-to-date graphics driver is not sufficient).
You may want to consider trying DirectCompute (Microsoft's version of GPU programming) or doing your OpenCL work on a Snow Leopard Mac. Those are the two ways (that I know of) that you can deliver a GPU programming solution to another user without any driver or other installation hassle.

Resources