locked
Surveyor SRV-1 camera service? RRS feed

  • Question

  •  I'm trying to figure out how exactly i'd get an image from the camera, and into an m x n x l matrix (an RGB image matrix).

     

    As i've been trying to use the webcam tutorial, and trying to couple it with the SRV-1 camera.config manifest but I havn't had any luck in getting it to work.

     

    Being the pissweak coder that I am (image processing in matlab is about all I got and some introductory java) i've been struggling to get any information from looking at the csharp code of the srv camera service.

    ¬_¬

     

    Soon as I can get this done, I can start implementing my vision algorythms in csharp. ^__^

     

     

    Wednesday, May 16, 2007 2:27 AM

Answers

  •  In Surveyor SRV-1 the camera is implementing the generic camera service and it provides two modes of vision. First is the camera image view which gets the frame as it is captured, and the other is the scan view that retrieves the processed blob data from firmware and from that creates an image to visualize those scan data. When the camera is switched to scan view it won’t fetch the complete image as the frame is processed on the robot firmware and only the processed data is passed to the PC which makes the serial transfer faster. If you want to do your own image processing on the captured frame you can either do it in the Vision class as a new camera mode or do it at service level by creating a new camera service that will internally make a QueryFrame request to the SRV-1 camera and then process the image. I would choose the first option because it needs less calls to grab each frame and also lets you switch between camera modes in the browser camera view. To get an idea, see the CameraCollection class in Vision.cs. There you can add a new instance of camera. Note the GetEnumerator returns the two types of cameras I said above. Each camera instance includes a name and a list of supported resolutions. The CaptureSurveyorFrame method returns the bitmap for the selected camera which is in turn used by FrameGrabber. I hope this gives you some hint to figure out how to implement your vision logic.

     

    Monday, May 28, 2007 8:49 PM

All replies

  •  In Surveyor SRV-1 the camera is implementing the generic camera service and it provides two modes of vision. First is the camera image view which gets the frame as it is captured, and the other is the scan view that retrieves the processed blob data from firmware and from that creates an image to visualize those scan data. When the camera is switched to scan view it won’t fetch the complete image as the frame is processed on the robot firmware and only the processed data is passed to the PC which makes the serial transfer faster. If you want to do your own image processing on the captured frame you can either do it in the Vision class as a new camera mode or do it at service level by creating a new camera service that will internally make a QueryFrame request to the SRV-1 camera and then process the image. I would choose the first option because it needs less calls to grab each frame and also lets you switch between camera modes in the browser camera view. To get an idea, see the CameraCollection class in Vision.cs. There you can add a new instance of camera. Note the GetEnumerator returns the two types of cameras I said above. Each camera instance includes a name and a list of supported resolutions. The CaptureSurveyorFrame method returns the bitmap for the selected camera which is in turn used by FrameGrabber. I hope this gives you some hint to figure out how to implement your vision logic.

     

    Monday, May 28, 2007 8:49 PM
  • Hi,

     

    Did you get this working? I tried but it doesn't seem to work.

     

    How would I do it as a service to get a frame? In the old SRV console it just does 'I' but for writing a service i'm not so sure. All I want is the image not the scan view from the firm ware at the lowest resolution stored into a RGB matrix and be able to pass that to something else. What references are needed?

     

    say, do I add robotics.common.proxy and something else like a surveyor dll? then setting up the contracts like this:

     

    using camera = <some library thing>  (which one?)

     

    [Partner("camera", Contract = camera.Contract.Identifier,
        CreationPolicy =
    PartnerCreationPolicy.UseExisting)]
    private camera.cameraOperations _cameraPort = new camera.cameraOperations();

     

    (then in the datamembers)

    public matrix frame

     

    then have a handler for the camera like:

     

    private void camerahandler(camera.Update)
    {

       frame = frameGrabber(size);

    }

     


    Im probably way off the mark; i need some real guidance here.

     

    Thursday, June 28, 2007 3:42 AM
  • Hi,

     

    Sorry for responding late. The SRV-1 camera service should be updated to implement the generic WebCam service as an alternate contract. This allows the simple image processing service that you are going to write to work with all camera services that extend the generic camera. However, with the current SRV-1 camera you need to directly partner with this robot’s camera even though its operations are almost identical to those of the generic camera.

     

    To use the SRV-1 camera service you need to reference the Surveyor.Srv1.Y2006.M11.Proxy.dll assembly, and partner with the srv1 camera in your image processing service.

     

    using srv1cam = SharpLogic.Robotics.Services.Surveyor.Srv1.Camera.Proxy;

     

    Then in the service class define the partnership like this:

     

    [Partner("Srv1cam", Contract = srv1cam.Contract.Identifier, CreationPolicy = PartnerCreationPolicy.UseExistingOrCreate)]

            srv1cam.Srv1CameraServiceOperations _srv1CamPort = new srv1cam.Srv1CameraServiceOperations();

     

    Next you need to get the frame from the camera. You can do this by subscribing to the srv1cam.UpdateFrame notification. (see Service Tutorial 5 - Subscribing) and on each UpdateFrame notification send a srv1cam.QueryFrame request to the camera port. You may also defining a timer in your service (see Service Tutorial 2) and send a srv1cam.QueryFrame request to the camera port on short intervals. In either case, when receiving and handling the QueryFrameResponse you will get a whole image as a byte attay that you can process in your handler.

     

    If you wanted to modify the SRV-1 camera service to implement the generic webcam, see the MultiDeviceWebCam sample in samples\Sensors\WebCam\WebCam.sln as an example.

     

    I know I’m giving very general hints but you can get a lot more information in the samples. By the way, the next release of MSRS will come with a simple vision sample service that will cover everything I said here. Expect it in a few weeks.

     

    Thanks

     

     

    Thursday, July 5, 2007 8:44 PM
  • boksofrox,

     

    The MSRS v1.5 is released today. When you download and install it, you can see a simple vision service under samples\Misc\SimpleVision directory. It shows how to do simple image processing using a webcam.

     

    Get it from here and have fun.

    Monday, July 9, 2007 8:01 PM
  • Omid -

    I just downloaded the new MSRS 1.5, and it compiles the Surveyor services properly, though I did first clear the PLATFORM=MCD environment variable.  The drive services work fine, but I can't get any video services running.

    C:\Microsoft Robotics Studio (1.5)\samples\Platforms\Surveyor\SRV-1>startcamera
    Turn on the SRV-1 robot and then press a key to load the service.
    Refresh the browser when DSS services are fully loaded.

    Press any key to continue . . .
    *   Service uri:  [07/10/2007 08:28:50][http://srv1host:50000/directory]
    *   Service uri:  [07/10/2007 08:28:50][http://srv1host:50000/constructor/501d2a
    25-e2cb-460d-8d51-617dd09b1bdc]
    *   Starting manifest load: file:///C:/Microsoft%20Robotics%20Studio%20(1.5)/sam
    ples/config/Surveyor.SRV1.Camera.manifest.xml [07/10/2007 08:28:51][http://srv1h
    ost:50000/manifestloaderclient]
    *   Manifest load complete [07/10/2007 08:28:52][http://srv1host:50000/manifestl
    oaderclient]

    It seems to load properly, but accessing http://localhost:50000/camera/live produces HTTP error 410 - "the page does not exist".

    Any ideas ?

    Thanks
    Howard

    Tuesday, July 10, 2007 3:46 PM
  • Hello Howard,

     

    I remember I had to close the browser and open the page again in another browser window or tab (in IE 7) maybe because of caching in IE I was not able to see the page when it was first opened. Also try viewing the page in firefox. One more thing, I noticed the SRV-1's scan view does not work well with the latest firmware but the rest of services (drive, IR sensors, camera) work fine. Please let me know if reopening the page didn't fix it. If that was the issue then perhaps you should take out the line from the batch file that opens the browser automatically.

     

    BTW did you see this post Joseph posted on the blog? They are using Surveyor SRV-1's camera service with RoboRealm's image processing.

     

    Thanks,

    Omid

     

    Tuesday, July 10, 2007 4:41 PM
  • Okay - that seemed to fix it. 

    The only issue with Scan is that there was a firmware change at the beginning of the year that changed the format of the scan data from decimal to hex, so that might be causing the problem.  I'll take a quick look at the scan service code, though maybe you know what needs to change.

    I did see Joseph's blog - we've been working with RoboRealm for a while, as they have direct support for the SRV-1, so it's nice to see everything tie together.

    Thanks for your help. 

    Tuesday, July 10, 2007 4:50 PM
  • I took a look at the code and it looks like that we are already parsing the scan data as hex.

     

    Srv1Controller.cs

    private SerialResponse ParseSerialResponse()

    {

        .

        .

        .

        switch ((SerialCommands) this._responseBuffer[2])

        {

            case SerialCommands.Scan: // "##Scan - 0001020304..79\n"

            int columns = 80;

            int scanDataLength = 9 + (2 * columns) + 1;

            if (this._responseBufferLength < scanDataLength) { return null; }

            if (this._responseBuffer[scanDataLength - 1] == (byte)'\n')

            {

                string pixelColumnStr = Port.Encoding.GetString(this._responseBuffer, 9, this._responseBufferLength - 10)

                    .Replace(" ", "0");

                byte[] pixelColumnArray = new byte[columns];

                for (int i = 0; i < pixelColumnArray.Length; i++)

                {

                    pixelColumnArray[i] = Convert.ToByte(pixelColumnStr.Substring(2*i, 2), 16);

                }

                return new SerialResponse(SerialCommands.Scan, pixelColumnArray);

            }

            return null;

    .

    .

    .

     

     I don't have a SRV-1 at hand now to debug but you can put a breakpoint on the case statement above and see if the response data are processed right.

     

    Thanks

    Tuesday, July 10, 2007 5:35 PM
  • Now that I think of it, we added a bunch of image processing commands, including blob search and various scan functions, along with support for 16 different stored color ranges, since the time that the Surveyor services for MSRS 1.0 were released, and while we still support the original scan function, we no longer have the 'm' command to set it up.  I think we'll worry about this particular problem later, as everything else seems to be working correctly.

    Tuesday, July 10, 2007 5:59 PM