- Build display.cpp
- Set up pipe on Linux VM
- Run display application
- Run proxy/passthrough on Mac
- Start streaming from Raspberry Pi
Created
October 22, 2013 16:22
-
-
Save nsantorello/7103663 to your computer and use it in GitHub Desktop.
OpenCV stream from raspberry pi
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include "opencv2/highgui/highgui.hpp" | |
#include <iostream> | |
#include <stdio.h> | |
using namespace std; | |
using namespace cv; | |
int main( int argc, const char** argv ) | |
{ | |
cout << "Starting..." << std::endl; | |
CvCapture* URL= cvCreateFileCapture("/path/to/my/pipe/here"); | |
cout << "loaded pipe" << std::endl; | |
Mat image; | |
while (true) { | |
image = cvQueryFrame(URL); | |
if(! image.data ) // Check for invalid input | |
{ | |
cout << "Could not open or find the image" << std::endl ; | |
return -1; | |
} | |
namedWindow( "Display window", CV_WINDOW_AUTOSIZE );// Create a window for display. | |
imshow( "Display window", image ); // Show our image inside it. | |
cvWaitKey(1); // Wait for a keystroke in the window | |
} | |
return 0; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# On Linux VM | |
rm my_pipe; mkfifo my_pipe; nc -q 5 -l 5001 > my_pipe |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
./display |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# On Mac | |
nc -l 5002 | nc <your VM's ip> 5001 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# On Raspberry Pi | |
# ssh pi@ipaddress | |
# password is 'raspberry' | |
# -t 0 => stream infinitely. (t is in milliseconds) | |
# -fps 12 => stream at 12 fps | |
# -o - => output to stdout | |
raspivid -fps 12 -t 0 -o - | nc <your Mac's ip> 5002 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
g++ display.cpp -lopencv_core -lopencv_highgui -o display |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment