JPEG encoder with RidgeRun SDK?

JPEG encoder with RidgeRun SDK?

This question has suggested answer(s)

Does the RidgeRun SDK support still image capture and JPEG encoding?  All examples and posts I have seen on this forum so far only refer to video capture with MPEG output.

Which example, library, or interface should I explore to perform still image capture and JPEG encoding?

 

Thanks,

Mike

 

All Replies
  • Hi Mike,

    JPEG encoding is possible using RR SDK and Gstreamer. However, it hasn't been tested on DM355, only in DM6446.

    Regards,

    Cristina

    Cristina Murillo

    Embedded Software Engineer, RidgeRun

  • Hi Cristina,

    Thanks for the reply!  I built the RR SDK and successfully captured an MPEG file to my SD card using the Gstreamer command from the RR blog entry here: www.ridgerun.com/blog.

    I've been working to learn Gstreamer better so I can properly request a single JPEG image.

    I tried this command, but it was unsuccessful because there wasn't enough space in the buffer pool.

        gst-launch v4l2src num-buffers=1 ! dmaienc_jpeg ! filesink location=test.jpg

    Do you have any advice?  I have enclosed the full console output below.

    Thanks,

    Mike

    / # loadmodules.sh

    [42949387.570000] CMEMK module: built on Feb  1 2010 at 16:43:54

    [42949387.570000]   Reference Linux version 2.6.29

    [42949387.580000]   File /opt/DM355SDK789311/proprietary/dvsdk_2_00_00/dvsdk_2_00_00_22/linuxutils_2_23_01/packages/ti/sdo/linuxutils/cmem/src/module/cmemk.c

    [42949387.620000] ioremap_nocache(0x87400000, 12582912)=0xc8000000

    [42949387.620000] allocated heap buffer 0xc8000000 of size 0xce000

    [42949387.650000] cmem initialized 8 pools between 0x87400000 and 0x88000000

    / # gst-launch v4l2src num-buffers=1 ! dmaienc_jpeg ! filesink location=test.jpg

    Setting pipeline to PAUSED ...

    [42949394.150000] mt9v113 1-003c: invalid control id 9963781

    [42949394.160000] mt9v113 1-003c: invalid control id 9963782

    [42949394.160000] mt9v113 1-003c: invalid control id 9963783

    [42949394.170000] mt9v113 1-003c: invalid control id 9963784

    [42949394.170000] mt9v113 1-003c: invalid control id 9963785

    [42949394.180000] mt9v113 1-003c: invalid control id 9963786

    [42949394.180000] mt9v113 1-003c: invalid control id 9963787

    [42949394.190000] mt9v113 1-003c: invalid control id 9963788

    [42949394.200000] mt9v113 1-003c: invalid control id 9963789

    [42949394.200000] mt9v113 1-003c: invalid control id 9963790

    [42949394.210000] mt9v113 1-003c: invalid control id 9963791

    [42949394.210000] mt9v113 1-003c: invalid control id 9963792

    [42949394.220000] mt9v113 1-003c: invalid control id 9963793

    [42949394.220000] mt9v113 1-003c: invalid control id 9963796

    [42949394.230000] mt9v113 1-003c: invalid control id 9963797

    [42949394.240000] mt9v113 1-003c: invalid control id 9963798

    [42949394.240000] mt9v113 1-003c: invalid control id 9963799

    [42949394.250000] mt9v113 1-003c: invalid control id 9963800

    [42949394.250000] mt9v113 1-003c: invalid control id 9963801

    [42949394.260000] mt9v113 1-003c: invalid control id 9963802

    [42949394.260000] mt9v113 1-003c: invalid control id 9963803

    [42949394.270000] mt9v113 1-003c: invalid control id 9963804

    [42949394.270000] mt9v113 1-003c: invalid control id 9963805

    [42949394.280000] mt9v113 1-003c: invalid control id 9963806

    [42949394.300000] vpfe-capture: hpitch = 640, vpitch = 480, bpp = 2

    [42949394.300000] vpfe-capture: adjusted hpitch = 640, vpitch = 480, bpp = 2

    [42949394.330000] vpfe-capture vpfe-capture: calling ccdc_config_raw()

    Pipeline is live and does not need PREROLL ...

    Setting pipeline to PLAYING ...

    New clock: GstSystemClock

    [42949394.510000] CMEMK Error: Failed to find a pool which fits 3686400

    CMEM Error: getPool: Failed to get a pool fitting a size 3686400

    Failed to allocate memory.

    ERROR: from element /GstPipeline:pipeline0/dmaienc_jpeg:dmaienc_jpeg0: No space left on the resource.

    Additional debug info:

    ../../src/src/gsttidmaienc.c(678): gst_tidmaienc_configure_codec (): /GstPipeline:pipeline0/dmaienc_jpeg:dmaienc_jpeg0:

    failed to create output buffers

    Execution ended after 143883042 ns.

    Setting pipeline to PAUSED ...

    Setting pipeline to READY ...

    gst-launch-0.10: Buffer.c:255: Buffer_getUserPtr: Assertion `hBuf' failed.

    Aborted

    / #

  • I would like to know a solution to this also.

    Thanks

    Chris

  • Hi,

    To avoid the pool size issue you should modify the sizes of the memory pools in the loadmodules.sh script which is generated by proprietary/dvsdk_2_00_00/Makefile. However, image encoding for the DM355 processor hasn't been tested.

    Regards,

    Cristina

    Cristina Murillo

    Embedded Software Engineer, RidgeRun

  • Thanks for the info.

    I tried a few things based on what I found in a Google search.

    Added:

    1x3686400

    To the end of the pools cmemk modprobe but error is:

    CMEMK Error: Failed to find a big enough free block

    CMEMK Error: alloc_pool failed to get contiguous area of size 3686400

    CMEMK Error: Failed to alloc pool of size 3686400 and number of buffers 1

    modprobe: failed to load module cmemk: Cannot allocate memory

    Do I have to assign cmemk more memory and less to "linux" during bootup?

    Thanks,

    Chris

  • Hi,

    You need to be careful about assigning more memory than the one that's available. If you add a pool that big, you should decrease or remove existing pools in order to compensate.

     

    Cristina Murillo

    Embedded Software Engineer, RidgeRun

  • Thanks for the help!  I was able to successfully capture a VGA camera image directly to a jpeg file after modifying loadmodules.sh as you suggested and executing the following gstreamer command:

        gst-launch v4l2src num-buffers=1 ! dmaienc_jpeg ! filesink location=test.jpg

    I've included a full log below.

    Regards,

    Mike

    ---------------------

    Modified /bin/loadmodules.sh to create /opt/loadmodules_buf.sh

    ---------------------

    #!/bin/sh

    # WARNING: this file is generated automatically, and any change will be overwritten by the Makefile

    # The reserved memory that is used by cmemk is cut from the end of RAM by the mem=XX param of the kernel

    # Original modprobe:

    # modprobe cmemk phys_start=0x87400000 phys_end=0x88000000 pools=1x2097152,2x1529856,7x829440,1x524288,1x108680,1x81920,2x8192,6x4096

    #

    # Modified modprobe:

    # Replaced 1x2097152 buffer and one of 2x1529856 buffer with 1x3686400 buffer.

    modprobe cmemk phys_start=0x87400000 phys_end=0x88000000 pools=1x3686400,1x1529856,7x829440,1x524288,1x108680,1x81920,2x8192,6x4096

    /sbin/mapdmaq

    modprobe dm350mmap

    rm -f /dev/cmem ; mknod /dev/cmem c `awk '$2 ~ /cmem/ {print $1}' /proc/devices` 0

    rm -f /dev/dm350mmap ; mknod /dev/dm350mmap c `awk '$2  ~ /dm350mmap/ {print $1}' /proc/devices` 0

    ---------------------------------------------------

    / # cd /opt

    /opt # ls

    dvsdk_demos          loadmodules_buf.sh   loadmodules_buf.sh~

    /opt # ./lo

    /opt # ./loadmodules_buf.sh

    [42949407.490000] CMEMK module: built on Feb  1 2010 at 16:43:54

    [42949407.490000]   Reference Linux version 2.6.29

    [42949407.510000]   File /opt/DM355SDK789311/proprietary/dvsdk_2_00_00/dvsdk_2_00_00_22/linuxutils_2_23_01/packages/ti/sdo/linuxutils/cmem/src/module/cmemk.c

    [42949407.550000] ioremap_nocache(0x87400000, 12582912)=0xc8000000

    [42949407.550000] allocated heap buffer 0xc8000000 of size 0xc0000

    [42949407.580000] cmem initialized 8 pools between 0x87400000 and 0x88000000

    /opt # gst-launch v4l2src num-buffers=1 ! dmaienc_jpeg ! filesink location=test.jpg

    Setting pipeline to PAUSED ...

    [42949447.530000] mt9v113 1-003c: invalid control id 9963781

    [42949447.540000] mt9v113 1-003c: invalid control id 9963782

    [42949447.540000] mt9v113 1-003c: invalid control id 9963783

    [42949447.550000] mt9v113 1-003c: invalid control id 9963784

    [42949447.550000] mt9v113 1-003c: invalid control id 9963785

    [42949447.560000] mt9v113 1-003c: invalid control id 9963786

    [42949447.560000] mt9v113 1-003c: invalid control id 9963787

    [42949447.570000] mt9v113 1-003c: invalid control id 9963788

    [42949447.580000] mt9v113 1-003c: invalid control id 9963789

    [42949447.580000] mt9v113 1-003c: invalid control id 9963790

    [42949447.590000] mt9v113 1-003c: invalid control id 9963791

    [42949447.590000] mt9v113 1-003c: invalid control id 9963792

    [42949447.600000] mt9v113 1-003c: invalid control id 9963793

    [42949447.600000] mt9v113 1-003c: invalid control id 9963796

    [42949447.610000] mt9v113 1-003c: invalid control id 9963797

    [42949447.620000] mt9v113 1-003c: invalid control id 9963798

    [42949447.620000] mt9v113 1-003c: invalid control id 9963799

    [42949447.630000] mt9v113 1-003c: invalid control id 9963800

    [42949447.630000] mt9v113 1-003c: invalid control id 9963801

    [42949447.640000] mt9v113 1-003c: invalid control id 9963802

    [42949447.640000] mt9v113 1-003c: invalid control id 9963803

    [42949447.650000] mt9v113 1-003c: invalid control id 9963804

    [42949447.660000] mt9v113 1-003c: invalid control id 9963805

    [42949447.660000] mt9v113 1-003c: invalid control id 9963806

    [42949447.680000] vpfe-capture: hpitch = 640, vpitch = 480, bpp = 2

    [42949447.690000] vpfe-capture: adjusted hpitch = 640, vpitch = 480, bpp = 2

    [42949447.710000] vpfe-capture vpfe-capture: calling ccdc_config_raw()

    Pipeline is live and does not need PREROLL ...

    Setting pipeline to PLAYING ...

    New clock: GstSystemClock

    [42949448.080000] CMEMK Error: FREE: Not a registered user of physical buffer 0x87c7c000

    Got EOS from ele[42949448.090000] CMEMK Error: FREE: Not a registered user of physical buffer 0x87a3b000

    ment "pipeline0".

    Execution end[42949448.100000] CMEMK Error: FREE: Not a registered user of physical buffer 0x874c5000

    ed after 2863858[42949448.110000] CMEMK Error: FREE: Not a registered user of physical buffer 0x874c4000

    73 ns.

    Setting [42949448.120000] CMEMK Error: FREE: Not a registered user of physical buffer 0x874ca000

    pipeline to PAUS[42949448.130000] CMEMK Error: FREE: Not a registered user of physical buffer 0x874c3000

    ED ...

    Setting [42949448.140000] CMEMK Error: FREE: Not a registered user of physical buffer 0x874c2000

    pipeline to READ[42949448.140000] CMEMK Error: FREE: Not a registered user of physical buffer 0x874c1000

    Y ...

    Setting p[42949448.150000] CMEMK Error: FREE: Not a registered user of physical buffer 0x874c0000

    ipeline to NULL ...

    CMEM Error: free: failed to free 0x412a2000

    CMEM Error: free: failed to free 0x41626000

    CMEM Error: free: failed to free 0x4121a000

    CMEM Error: free: failed to free 0x4121b000

    CMEM Error: free: failed to free 0x4121c000

    CMEM Error: free: failed to free 0x41230000

    CMEM Error: free: failed to free 0x41231000

    CMEM Error: free: failed to free 0x41232000

    CMEM Error: free: failed to free 0x41233000

    Freeing pipeline ...

    /opt #

    /opt # ls

    dvsdk_demos          loadmodules_buf.sh~

    loadmodules_buf.sh   test.jpg

    /opt # ls -al

    drwxr-xr-x    3 1000     1000         4096 Jan  1 00:01 .

    drwxr-xr-x   15 root     root         4096 Jan  1 00:01 ..

    drwxr-xr-x    3 1000     1000         4096 Feb 12  2010 dvsdk_demos

    -rwxr-xr-x    1 1000     1000          699 Feb 12  2010 loadmodules_buf.sh

    -rw-r--r--    1 1000     1000          565 Feb 12  2010 loadmodules_buf.sh~

    -rw-r--r--    1 root     root        38872 Jan  1 00:01 test.jpg

    /opt # sync

    /opt # sync

    /opt #

  • Hi Cristina,

    I understand that the jpeg encoding functionality is currently untested.  Is it on the RidgeRun SDK road map?  When do you think it will be well supported by the SDK?

    After taking a number of still pictures, gstreamer locks up.  I've seen it lock up after up to 40 pictures, and once it locked up after only 6 pictures.

    Thanks again,

    Mike

  • Hi Mike,

    Image encoding on DM355 is not on the road map yet, I'll post it here as soon as we work on it.

    Regards,

    Cristina

    Cristina Murillo

    Embedded Software Engineer, RidgeRun

  • Hi,

    Image encoding should be working now.

    If you want to capture just one frame, I would recommend the following pipeline instead:

    gst-launch v4l2src num-buffers=1 always-copy=true ! dmaiaccel ! dmaienc_jpeg sizeOutputMultiple=1 ! filesink location=test.jpg

    The parameter sizeOutputMultiple will reduce the amount of memory required by the element (since you are encoding only one frame), so no modification to the loadmodules is required.

    Be sure to have the latest SDK and the latest version of the plugins.

    Regards,

    Diego

  • What should I type in order to get a MJPEG video?

    gst-launch v4l2src num-buffers=1 always-copy=true ! dmaiaccel ! dmaienc_mjpeg sizeOutputMultiple=2 ! udpsink port=5000 host=192.168.1.108

    gives me the same buffer error

  • You would need a payloader for mpeg video, for which there is no "native" payloader AFAIK, so you will need a qt payloader (which doesn't exist in opensource yet AFAIK). This means you need to implement or get someone to implement a rtpxqtpay element

    Diego

  • Hey what about now (with the RR SDK that runs on Linux 2.6.32)? Using the 5MP camera:

    Using this pipeline, here is what I get:

    / # gst-launch v4l2src num-buffers=1 always-copy=true ! dmaiaccel ! dmaienc_jpeg ! filesink location=test.jpg

    Setting pipeline to PAUSED ...

    vpfe-capture vpfe-capture: IPIPE Chained

    Pipeline is live and does not need PREROLL ...

    ERROR: from element /GstPipeline:pipeline0/GstV4l2Src:v4l2src0: Device '/dev/video0' cannot capture at 2590x1942

    Additional debug info: ../../../src/sys/v4l2/v4l2src_calls.c(1470): gst_v4l2src_set_capture (): /GstPipeline:pipeline0/GstV4l2Src:v4l2src0:

    Tried to capture at 2590x1942, but device returned size 2176x1536

    ERROR: pipeline doesn't want to preroll.

    Setting pipeline to PAUSED ...

    Setting pipeline to READY ...

    Setting pipeline to NULL ...

    Freeing pipeline ...

    I had to remove the sizeOutputMultiple=1 because it was not recognized...

    Also, if I am trying the following, nothing is written in the file (but the pipeline is playing):

    gst-launch -e v4l2src always-copy=false ! video/x-raw-yuv,format=\(fourcc\)NV12, width=1280, height=720, framerate=\(fraction\)23/1 ! dmaiaccel ! dmaienc_jpeg ! filesink location=test.jpg

    Any idea why?

  • I have been trying the following command and successfully taken picture with *.yuv format

    gst-launch -e videotestsrc num-buffers=50 ! video/x-raw-yuv,format=\(fourcc\)NV12, width=1280, height=720, framerate=\(fraction\)23/1 ! filesink location=test000.yuv sync=false

  • I have been using the following to take pictures using a DM365 LM-5M03 combination but the pictures I am getting have very low color levels in addition to the colors not being correct ( greens look red etc...)

    gst-launch -e v4l2src always-copy=false num-buffers=1 ! video/x-raw-yuv,format=\(fourcc\)UYVY, width=1280, height=720 ! ffmpegcolorspace ! dmaienc_jpeg ! filesink location=720P_test.jpg

    Is there anything that can be done to the GStreamer pipeline so that I can get something like an uncomppressed BMP?