My team is currently working on streaming an image from GRIP on a kangaroo (baby PC) that will be located on the robot. The kangaroo has been set up to have a static IP address. We are able to create the grip program and run it on startup of the kangaroo, however i cannot for the life of me figure out where GRIP publishes its MJPG streams to. I have tried simply connecting to the port i got from the “GRIP SmartDashboard Extension” source file which i found (port 1180). However, when i attempt to connect to it in internet explorer and display the stream all i get is jibirish. (connecting to htttp://myKangarooIP:1180/. I’ve torn apart the smart dashboard extension a little bit and see that they use a Web Socket, but this is above my level of knowledge and i need to have this camera feed on my custom java dashboard before our first competition. Please Help! i’ll be forever in your debt.
heres a snibbit of my OpenCV code that is attempting to open the stream
essentially what is happening is i am starting a camera feed and setting the ImageView object called “currentFrame” in JavaFX to the image i am getting from the camera. It works when i give it “0” as the camera ID. however i cannnot give it an IP it just throws my error saying “Cannot open camera stream.” implying that it cannot decode or find an image stream.
// a timer for acquiring the video stream
private ScheduledExecutorService timer;
// the OpenCV object that realizes the video capture
private VideoCapture capture = new VideoCapture();
// a flag to change the button behavior
private boolean cameraActive = false;
// the id of the camera to be used
private static int cameraId = 0;
private static String cameraIP = "http://localhost:1181/?action=stream";
public final int port = 1180;
///?action=stream
@FXML
private void startCamera()
{
if (!this.cameraActive)
{
// start the video capture
this.capture.open(cameraIP);
// is the video stream available?
if (this.capture.isOpened())
{
this.cameraActive = true;
// grab a frame every 33 ms (30 frames/sec)
Runnable frameGrabber = new Runnable() {
@Override
public void run()
{
// effectively grab and process a single frame
Mat frame = grabFrame();
// convert and show the frame
Image imageToShow = Utils.mat2Image(frame);
updateImageView(currentFrame, imageToShow);
}
};
this.timer = Executors.newSingleThreadScheduledExecutor();
this.timer.scheduleAtFixedRate(frameGrabber, 0, 33, TimeUnit.MILLISECONDS);
// update the button content
this.button.setText("Stop Camera");
}
else
{
// log the error
System.err.println("Impossible to open the camera connection...");
}
}
else
{
// the camera is not active at this point
this.cameraActive = false;
// update again the button content
this.button.setText("Start Camera");
// stop the timer
this.stopAcquisition();
}
}
private Mat grabFrame()
{
// init everything
Mat frame = new Mat();
// check if the capture is open
if (this.capture.isOpened())
{
try
{
// read the current frame
this.capture.read(frame);
// if the frame is not empty, process it
if (!frame.empty())
{
//Imgproc.cvtColor(frame, frame, Imgproc.COLOR_BGR2GRAY);
}
}
catch (Exception e)
{
// log the error
System.err.println("Exception during the image elaboration: " + e);
}
}
return frame;
}
/**
* Stop the acquisition from the camera and release all the resources
*/
private void stopAcquisition()
{
if (this.timer!=null && !this.timer.isShutdown())
{
try
{
// stop the timer
this.timer.shutdown();
this.timer.awaitTermination(33, TimeUnit.MILLISECONDS);
}
catch (InterruptedException e)
{
// log any exception
System.err.println("Exception in stopping the frame capture, trying to release the camera now... " + e);
}
}
if (this.capture.isOpened())
{
// release the camera
this.capture.release();
}
}
/**
* Update the {@link ImageView} in the JavaFX main thread
*
* @param view
* the {@link ImageView} to update
* @param image
* the {@link Image} to show
*/
private void updateImageView(ImageView view, Image image)
{
Utils.onFXThread(view.imageProperty(), image);
}
/**
* On application close, stop the acquisition from the camera
*/
protected void setClosed()
{
this.stopAcquisition();
}
opening the camera IP in windows explorer results in a load of jibbirish and a crashed browser so there is something there just not what i want.