0
$\begingroup$

Rosanswers logo

Hi, all,

I want to use rosbridge, gscam to load the video from the Webcam through socket

on the browser, but no matter how I use the example from the brown-ros-pkg, I can't make it run. To make my question more clear, I put similar code from brown-ros-pkg first, and I will show what I have tried after the code:

The code is

          String ip = "ws://Control:9090";

          //Variable to save rgb image
          PImage img;

           int     scrWidth;
           int     scrHeight;
           int     i;
           i=1;
           boolean lock2;
           boolean isRunning;

           void setup()
          {
            img = createImage(640, 480, RGB);
            scrWidth = img.width;
            scrHeight = img.height;

            size(scrWidth, scrHeight);
            background(125);
            fill(255);

            noLoop();
            connect(ip);
            println("Hello after connect!\n");
            isRunning = false;

            lock2 = false;
            }


            void draw()
            {

             if(isRunning)
             {image(img, 0, 0, scrWidth, scrHeight);
               println(" draw inside ");}
              }

             void run()
             {
               //Subscribe GStreamer pipeline
                 println("Hello run!");
                 subscribe('/gscam/image_raw',getCamStream);

                 frameRate(30);
                 loop();
                 isRunning = true;

                  println("Start");
               }

               void stop()
               {
                   println("Hello stop!");
                   isRunning = false;
                   noLoop();
                   println("Stop");
                }

               void getCamStream(msg)
              {

                if(lock2)
                return;

                lock2 = true;
                //msg.uri is a rgb data of streaming message
                img = loadImage(msg.uri);  
                 println("Hello getcamstream!\n");
                 lock2 = false;
               }

To test this code, I use the brown-ros-pkg recommends website: ROSProcessingjs Test suite.

Before I test, I already got the newest rosbridge package, the driver for the GSCam (I can see the image from the camera by running the node:

             $ rosrun image_view image_view image:=/gscam/image_raw)

My lab does not have irobot, I want do test whether the image could transit to browser or not, so I run roscore, rosbridge and gscam.

However, I could not load image to the default area, even the program could be initialized and subscribe the topic, and page ROSProcessingjs Test suite is always killed by itself, I also tried many ways:

(1) I doubt about the "frameRate() and loop()", because in processing.js official site, it tells me that loop() enables the draw() to work, but without any other functions, so even I delete the frameRate() or loop(), I only get lots of print "Hello getcamstream".

(2) I copy the subscribe() to draw(), it doesn't work

(3) by using rxgraph, I can see the "/gscam/image_raw" links "/rosbridge" well, but links "/image_view" with big red circle.

Can anyone give me little hint about where I was wrong? 
Thanks a lot!

Originally posted by tairen on ROS Answers with karma: 56 on 2012-04-07

Post score: 2

$\endgroup$

1 Answer 1

0
$\begingroup$

Rosanswers logo

Hello,

You were not doing anything wrong but it was because the code is just out dated.

Instead of using rosbridge to stream a image topic through video, I would recommend to use mjpeg_server to stream a image topic to the web. It provides more promising way to transport image to web.

Check out http://www.ros.org/wiki/mjpeg_server

If you like to use Procesingjs capability on top of video stream, You can use MJPEG camera example, which requires both mjpeg_server and rosbridge.

Regards, Jihoon


Originally posted by jihoonl with karma: 634 on 2012-04-14

This answer was ACCEPTED on the original site

Post score: 4


Original comments

Comment by tairen on 2012-04-14:
Thanks a lot, Jihoon. I already figure out just like you said.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.