ModalAI Forum
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Register
    • Login

    Minimal example of using camera_cb

    VOXL m500 Reference Drone
    6
    17
    1319
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • PawelJP
      PawelJ
      last edited by

      Thank you all for all of the information :). The snapshot feature sounds like what I'm looking for. I'm looking through the camera server git at the moment for the code. Is there any example for using this vs a regular stream? I see that in the camera server conf you can enable which type of stream you want. I've set preview and video to false for the hires camera and set snapshot to True. My tflite model is using the tracking camera for it's feed. Going off of the voxl-camera-server hal3-camera-mgr.cpp I see that the server handles the image saving. As for the expected behaviour, would an image be saved when data enters the pipe while the client is still connected?

      I currently have my client set with a simple camera_cb that closes the client when the cb is triggered to only save one image after the client is started. Is the snapshot client setup the same way as the streaming client? When I try to run this client with the pipe name pointing to /run/mpa/hires_preview I get the debug message showing that the client connected, but it appears that the capture buffer is being used instead of the snapshot.

      NOTE: I added the all caps printouts that show that pCaptureResultData is not null on line 1115 of the hal3_camera_mgr.cpp and that it is null on line 1240 when checkin the pSnapshotBufferInfo.

      ------ voxl-camera-server INFO: Client: modal-abr-capture-pipe0 connected to channel: 0
      
      
      2:CAPTURE BUFFER NOT NULL, BUT SHOULD BE FOR SNAPSHOT
      
      
      
      SNAPSHOT BUFFER NULL WHEN TRYING TO SAVE
      
      voxl-camera-server ERROR: Error sending request 0, ErrorCode: -22
      
      voxl-camera-server FATAL: Recieved Fatal error from camera: hires
                                Camera server will be stopped
      ------ voxl-camera-server WARNING: Thread: hires request thread recieved ESTOP
      ------ voxl-camera-server WARNING: Thread: tracking result thread recieved ESTOP
      ------ voxl-camera-server WARNING: Thread: stereo request thread recieved ESTOP
      ------ voxl-camera-server WARNING: Thread: stereo result thread recieved ESTOP
      ------ voxl-camera-server WARNING: Thread: hires result thread recieved ESTOP
      ------ voxl-camera-server WARNING: Thread: tracking request thread recieved ESTOP
      
      ------ voxl-camera-server INFO: Camera server is now stopping
      		There is a chance that it may segfault here, this is a mmqcamera bug, ignore it
      
      ------ voxl-camera-server INFO: Stopping tracking camera
      ------ voxl-camera-server INFO: tracking camera stopped successfully
      
      ------ voxl-camera-server INFO: Stopping hires camera
      ------ voxl-camera-server INFO: hires camera stopped successfully
      
      ------ voxl-camera-server INFO: Stopping stereo camera
      ------ voxl-camera-server INFO: stereo camera stopped successfully
      
      ------ voxl-camera-server INFO: Camera server exited gracefully
      
      

      I'm still sorting through where this error is being thrown.

      1 Reply Last reply Reply Quote 0
      • Alex KushleyevA
        Alex Kushleyev ModalAI Team
        last edited by

        I double checked with other devs on the team and the jpeg snapshot feature in voxl-camera-server is still in development. I don't have a good ETA for the feature.

        However, perhaps we can go back to evaluating voxl-rtsp for your application. If you disable hires camera in voxl-camera-server, you should be able to use voxl-rtsp with hires camera after voxl-camera-server has started for other cameras.

        voxl-rtsp supports outputting jpegs. You can first confirm that you can access hires camera jpegs with voxl-rtsp (I don't think it can do 4K30 jpegs, but lower resolution/frame rate should work). That should work and then you could add an input to trigger voxl-rtsp to actually save a jpeg upon request (instead of every frame). This can be done similarly how exposure/gain commands are accepted by voxl-rtsp via a named pipe.

        Hopefully this can work for you..

        1 Reply Last reply Reply Quote 1
        • Alex KushleyevA
          Alex Kushleyev ModalAI Team
          last edited by

          .. or if you wanted to continue using voxl-camera-server for 4K, just modify the server to save yuv frames on-demand and convert to jpeg later, as we discussed above..

          1 Reply Last reply Reply Quote 1
          • PawelJP
            PawelJ
            last edited by

            Thank you for all of the ideas. I was able to get the image capture to work by setting my thread to watch for a capture_image flag to start the client, then stop it after the image is saved, instead of threading the callback itself. This let me save an image at a time to text file, then I just scp it off the voxl to parse in python as an RGB image later.

            Cheers

            1 Reply Last reply Reply Quote 0
            • Alex KushleyevA
              Alex Kushleyev ModalAI Team
              last edited by

              Sounds good.. Just keep in mind that saving a 4K image to a text file will be much slower and will take more space than just saving the raw binary data to a file. Parsing a binary file should be as easy or easier than text.. It's up to you though 🙂

              PawelJP 1 Reply Last reply Reply Quote 0
              • PawelJP
                PawelJ @Alex Kushleyev
                last edited by

                @Alex-Kushleyev thanks for the heads up. You make a good point, I'll switch it over to a bin 👌 Thanks!

                1 Reply Last reply Reply Quote 0
                • M
                  m1baldwin
                  last edited by

                  Just coming back to this; any update on the snapshot feature?

                  1 Reply Last reply Reply Quote 0
                  • ?
                    A Former User
                    last edited by

                    Hi,
                    voxl-camera-server >= 1.0.2 (live on voxl2/rb5, beta on voxl1) supports 4k snapshots from the hires camera, you can echo "snapshot" into the hires control pipe and it will write the snapshot out to /data/snapshots/, or echo "snapshot [path]" into the pipe and it will write the snapshot out to the given path.

                    M 1 Reply Last reply Reply Quote 0
                    • M
                      mkwan @Guest
                      last edited by

                      @Alex-Gardner I get an error when trying snapshot on the Sentinel, voxl-suite 0.8.1.

                      Input:

                      voxl2:/run/mpa/hires$ echo "snapshot" > control
                      

                      Output:

                      Nov 04 16:20:41 m0054 bash[24392]: Camera: hires taking snapshot (destination: /data/snapshots/hires-0.jpg)
                      Nov 04 16:20:41 m0054 bash[24392]: free(): invalid pointer
                      Nov 04 16:20:41 m0054 systemd[1]: voxl-camera-server.service: Main process exited, code=killed, status=6/ABRT
                      Nov 04 16:20:41 m0054 systemd[1]: voxl-camera-server.service: Failed with result 'signal'.
                      

                      Any advice?

                      ? 1 Reply Last reply Reply Quote 0
                      • ?
                        A Former User @mkwan
                        last edited by

                        @mkwan Can you make a new thread with this issue and include the output of voxl-inspect-services -v

                        1 Reply Last reply Reply Quote 0
                        • First post
                          Last post
                        Powered by NodeBB | Contributors