|
|
|
![]() |
|
|||||||
|
||||||||
![]() |
|
|
Thread Tools | Rate Thread | Display Modes |
|
|
|
#1
|
|||
|
|||
|
Help With Raspberry Pi Camera Stream
Hello, recently I was able to get a USB camera plugged into a raspberry pi 3 to stream via MJPEG streamer. Before we had two usb cameras plugged into the RIO and swapped via this code which has now been modified to theoretically work with the pi stream. However, when I try this, I either get a too many simultaneous streams error, or an error saying that the address specified cannot be reached.
I have the MJPEG stream also set to stream port 1180. Any tips on how to get this working? Also, am I better off just putting this switcher logic on the pi and grab the switch button via Network Tables? Code:
public void robotInit() {
Thread t = new Thread(() -> {
boolean allowCam1 = false;
UsbCamera camera1 = CameraServer.getInstance().startAutomaticCapture(0);
camera1.setResolution(320, 240);
camera1.setFPS(30);
HttpCamera piCam = new HttpCamera("piCam", "http://10.23.170.203:1180/?action=stream", HttpCameraKind.kMJPGStreamer);
CvSink cvSink1 = CameraServer.getInstance().getVideo(camera1);
CvSink cvSink2 = CameraServer.getInstance().getVideo(piCam);
CvSource outputStream = CameraServer.getInstance().putVideo("Switcher", 640, 480);
Mat image = new Mat();
while(!Thread.interrupted()) {
if(oi.getGamepad().getRawButton(9)) {
allowCam1 = !allowCam1;
Timer.delay(1);
}
if(allowCam1){
cvSink2.setEnabled(false);
cvSink1.setEnabled(true);
cvSink1.grabFrame(image);
} else{
cvSink1.setEnabled(false);
cvSink2.setEnabled(true);
cvSink2.grabFrame(image);
}
outputStream.putFrame(image);
}
});
t.start();
|
|
#2
|
|||
|
|||
|
Re: Help With Raspberry Pi Camera Stream
Can you also post the code that is running on the Raspberry Pi?
Also, you should check the url for the camera/raspberry pi, because it ordinarily takes the form 10.TE.AM.xxx and yours appears to not. This may be the source of the address specified not reached error. Hope this helps. Last edited by jmcculloch : 02-02-2017 at 00:08. Reason: Wrote that the port that is used when startautomaticcapture is run is 1180, but it is actually 1181 |
|
#3
|
|||
|
|||
|
Re: Help With Raspberry Pi Camera Stream
This is the command run from a script inside the pi:
mjpg_streamer -o "output_http.so -w ./www -p 1180" -i "input_uvc.so -f 15 -r 640x480 -y -n" & It outputs the stream to the Raspberry Pi's IP address, not the robot's IP. Maybe I should try getting mDNS on the pi and try using raspberrypi.local? Last edited by thecoopster20 : 02-02-2017 at 07:30. |
|
#4
|
|||
|
|||
|
Re: Help With Raspberry Pi Camera Stream
Alright, I figured it out. Rather than hook the cameras into the pi and stream from there, I've kept the cameras on the RIO and then I grab the "Switcher" stream's ip and use that for GRIP. Makes everything a heck of a lot easier to manage as well, since I don't have to worry about the settings for the pi getting properly executed and started.
|
![]() |
| Thread Tools | |
| Display Modes | Rate This Thread |
|
|