2
$\begingroup$

I'm building a quadcopter using Raspberry Pi. There is the Pi Camera connected to the Raspberry Pi which is streaming the captured video. I can connect to this stream via Wi-Fi on my notebook (Linux) by using the console command "nc" and then show it by "mplayer".

What I want to do though is avoid the console commands and connect to this stream directly through my Java application. The reason is I want to do some image processing operations with this video so I need to have it in my application.

Is there anyone able to help me?

$\endgroup$
2
  • $\begingroup$ Welcome to Robotics user285066, but I'm afraid that as it stands, this looks like a library recommendation question. We prefer practical, answerable questions based on actual problems that you face, so questions which ask for a list of approaches or a subjective recommendation on a method (for how to build something, how to accomplish something, what something is capable of, etc.) are off-topic. Please take a look at How to Ask & tour for more information on how stack exchange works. $\endgroup$ – Mark Booth Oct 24 '16 at 10:21
  • $\begingroup$ In the meantime however, you may want to browse questions in the computer-vision and opencv tags. $\endgroup$ – Mark Booth Oct 24 '16 at 10:21
0
$\begingroup$

Alternatively, you could embrace the console commands instead of avoiding them, and still have it interact with your java program. This would have the advantage of continuing to deliver the video stream to the notebook even if the java program fails.

I'd look at mkfifo, which will make a special file on your system that the java program could open for processing.

To put data into that file, use the tee command to copy the input data from STDIN to both STDOUT and the FIFO file you created.

e.g.

bash# mkfifo /path/to/myOutputFifo
bash# nc | tee /path/to/myOutputFifo | mplayer

Then, point your java program at /path/to/myOutputFifo for input.

$\endgroup$
2
  • $\begingroup$ Thanks this is a good to know but it not solve my problem. How can I decode that videostream in java appliaction? $\endgroup$ – user285066 Dec 22 '14 at 22:51
  • $\begingroup$ That depends entirely on the nature of the video stream that you're decoding, and it sounds like a question for a different StackExchange site. $\endgroup$ – Ian Dec 24 '14 at 0:43
0
$\begingroup$

You should check it out OpenCV (open computer vision) it suport bindings for java and stream and it has very powerfull image processing tools! Hope it helps... OpenCV java stream stackoverflow

$\endgroup$
6
  • $\begingroup$ It is possible but it seems to much complicated to use OpenCV in Jave when there is library in Java supporting operations needed. There must be way how connect to the stream directly from Java. $\endgroup$ – user285066 Nov 28 '14 at 21:51
  • $\begingroup$ Well you can make stream directry from java library but in OpenCV is much nicer and its not so complicated :) $\endgroup$ – user7586 Nov 28 '14 at 21:58
  • $\begingroup$ Well finally I use OpenCV 2.4.9 and it's working nice and easy. Unfortunatelly JavaCV isn't working. $\endgroup$ – user285066 Dec 24 '14 at 14:27
  • $\begingroup$ Well then don't give up try with python my friend :D you will have less problems, the python should be already installed on linux os, and its super easy :D $\endgroup$ – user7586 Dec 24 '14 at 20:12
  • $\begingroup$ Man... I have enaugh troubles with some example OpenCV codes written nonsensly in Python instead of C++. Any non-C/C++/Java/C# PL needed at all especially on C/C++ based linux - I don't see reason for that. There is so much lacking of some quality C++ libraries - why add troubles with Python. $\endgroup$ – user285066 Dec 25 '14 at 23:29
0
$\begingroup$

I think this should be possible. You could still run nc on the pi side, and use a socket connection in your java application.

One important aspect is the encoding of the stream. It would probably be easiest to use mjpeg here. Mjpeg is just a concatenation of single jpeg images, and decoding jpegs is much easier than h.264 (the other alternative in the raspivid as far as I recall).

The server could e.g. be

raspivid -t 0 -w 300 -h 300 -hf -fps 20 -codec MJPEG -o - | nc -l 4000

On the client side you could look for example at this mjpeg-viewer to get you started.

The support for MJPEG in the raspivid seems to be recent. I don't know if this will work.

$\endgroup$

Not the answer you're looking for? Browse other questions tagged or ask your own question.