Sony's Developer World forum

    • Home
    • Forum guidelines

    Capture video from spresense camera board using arduino

    Spresense
    4
    9
    4969
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    This topic has been deleted. Only users with topic management privileges can see it.
    • R
      raghulax last edited by

      HI,

      I'm new to spresense. I could able to run sample applications (hello world using nuttx) and sample Camera and led blink and other apps on spresense using arduino.

      Now, i'm trying to create an app in arduino to capture video and save it onto SD Card. Already tried the camera app where images are stored on SD card. Now, instead of images, i want to capture video. Not sure how to do that.

      CamErr CameraClass::startStreaming ( bool enable,
      camera_cb_t cb = NULL
      )

      The above API will store the video images onto 'camera_cb_t' which is nothing but CamImage class. But, CamImage class don't have any methods to retrieve video.

      I need help in capturing video using arduino and spresense API. Any help in this regard in highly appreciated.

      Thanks very much in advance,

      1 Reply Last reply Reply Quote
      • TE-KarlKomierowski
        TE-KarlKomierowski DeveloperWorld last edited by

        Hi @raghulax

        There is no direct library to store the captured video stream to a (compressed) video file on the SD card.

        There is one project that streams video data from Spresense to a PC. Maybe this might give you inspiration:

        https://www.hackster.io/mhanuel/ipv6-web-camera-powered-by-wiz610io-adf28b

        Otherwise you would have to either find a suitable library that can create a video for you or write something by your self.
        BR
        Karl

        R J 2 Replies Last reply Reply Quote
        • R
          raghulax @TE-KarlKomierowski last edited by

          Thanks very much Karl for the reply. I was away for few days, so didn't get a chance to look at the sample project.

          Is there a way I can capture video from CameraClass ...... storing on SD card is not needed. If i can capture video and save onto PC also fine. Basically i need code snippet on how to capture video. I know basics of C language not a advanced C programmer. The sample project that you referred i think uses C++ language which i'm not aware of. So, bit difficult to catch up on code wise.

          If there is some code available to capture video using spresence library, that would be great. If so, please provide the pointers,

          Thanks very much in advance.
          Laxmi

          TE-KarlKomierowski 1 Reply Last reply Reply Quote
          • TE-KarlKomierowski
            TE-KarlKomierowski DeveloperWorld @raghulax last edited by TE-KarlKomierowski

            @raghulax said in Capture video from spresense camera board using arduino:

            Thanks very much Karl for the reply. I was away for few days, so didn't get a chance to look at the sample project.

            Hi @raghulax

            The data you get from the camera if you stream it is simply stream of raw, uncompressed frames. If you want to send these to a PC you have to get some sort of connectivity. USB should work just fine, you could then compile the frames to a known video format on the PC.

            In this project I am fetching the frames from the camera and display them on a TFT display. You could do the same but send the frames to your PC instead.
            https://www.hackster.io/karl-sony/gauge-reader-using-spresense-camera-ae5d45

            BR
            Karl

            Is there a way I can capture video from CameraClass ...... storing on SD card is not needed. If i can capture video and save onto PC also fine. Basically i need code snippet on how to capture video. I know basics of C language not a advanced C programmer. The sample project that you referred i think uses C++ language which i'm not aware of. So, bit difficult to catch up on code wise.

            If there is some code available to capture video using spresence library, that would be great. If so, please provide the pointers,

            Thanks very much in advance.
            Laxmi

            R 1 Reply Last reply Reply Quote
            • R
              raghulax @TE-KarlKomierowski last edited by

              Thanks Karl for the pointer.

              Let me work on it and get back to you if i get stuck.

              Thanks & Regards,
              Laxmi

              R 1 Reply Last reply Reply Quote
              • R
                raghulax @raghulax last edited by

                One more question. I found that we can create video from libJPEG. But i'm not sure how to access linux file system from spresense board. How to get handle on linux File system? In the below arduino example code, the bold lines write file to SD card ..... how to write the same to PC instead?

                if (img.isAvailable())
                {
                /* Create file name */

                      char filename[16] = {0};
                      sprintf(filename, "PICT%03d.JPG", take_picture_count);
                
                      Serial.print("Save taken picture as ");
                      Serial.print(filename);
                      Serial.println("");
                
                      /* Remove the old file with the same file name as new created file,
                       * and create new file.
                       */
                
                      **theSD.remove(filename);
                      File myFile = theSD.open(filename, FILE_WRITE);
                      myFile.write(img.getImgBuff(), img.getImgSize());
                      myFile.close();**
                    }
                

                Sorry if the question is too basic. I'm just learning.

                TE-KarlKomierowski 1 Reply Last reply Reply Quote
                • TE-KarlKomierowski
                  TE-KarlKomierowski DeveloperWorld @raghulax last edited by

                  @raghulax you can't open a file on your PC from Spresense by a simple function call.
                  You would have to transfer the data from Spresense to PC first.
                  This can be done using UART if you don't mind having a wired connection with limited throughput 1MBps or so.
                  You could either use a already existing protocol (maybe xmodem?) or write something your self.
                  You will have to run something on your PC to initiate and receive the sent data.

                  But the short answer is that there is no simple way of just opening a file from Spresense on the PC to store files.

                  BR
                  /Karl

                  @raghulax said in Capture video from spresense camera board using arduino:

                  One more question. I found that we can create video from libJPEG. But i'm not sure how to access linux file system from spresense board. How to get handle on linux File system? In the below arduino example code, the bold lines write file to SD card ..... how to write the same to PC instead?

                  if (img.isAvailable())
                  {
                  /* Create file name */

                        char filename[16] = {0};
                        sprintf(filename, "PICT%03d.JPG", take_picture_count);
                  
                        Serial.print("Save taken picture as ");
                        Serial.print(filename);
                        Serial.println("");
                  
                        /* Remove the old file with the same file name as new created file,
                         * and create new file.
                         */
                  
                        **theSD.remove(filename);
                        File myFile = theSD.open(filename, FILE_WRITE);
                        myFile.write(img.getImgBuff(), img.getImgSize());
                        myFile.close();**
                      }
                  

                  Sorry if the question is too basic. I'm just learning.

                  1 Reply Last reply Reply Quote
                  • J
                    juvt @TE-KarlKomierowski last edited by

                    Hi @TE-KarlKomierowski
                    I would like to do video recording on SD card. Is it really possible on Spresense?
                    What are keywords to search for a library or process to do that?

                    C 1 Reply Last reply Reply Quote
                    • C
                      CamilaSouza DeveloperWorld @juvt last edited by

                      Hi, @juvt
                      The camera example (https://github.com/sonydevworld/spresense-nuttx-apps/tree/new-master/examples/camera) takes pictures and saves them in the sd card. It has a mode to display the camera image continuously, but it doesn't save that one. You could try and modify this code to also be able to save the video in the sd card.

                      1 Reply Last reply Reply Quote
                      • First post
                        Last post
                      Developer World
                      Copyright © 2021 Sony Group Corporation. All rights reserved.
                      • Contact us
                      • Legal