Write jpeg faster from 6 cameras

Hi,
my setup is Agx Devkit 32gb, JP4.6.1, 6x imx577 with hardware sync, framerate 10FPS, ssd SAMSUNG EVO 970 nvme.

Without “parallel for” writing jpeg takes about 33ms per camera, total ~6*33ms.
With “parallel for” it takes same time, so multithreading not works for writeJpeg.
How to speedup writing jpegs?

I need <90ms for all 6 cameras.

Here my code to write jpegs from all cameras.

size_t cameraId{};
#pragma omp parallel for schedule(static) num_threads(6) 
            for( cameraId = 0; cameraId < m_camerasNum; ++ cameraId )
            {
                const auto result{ m_iCaptureSessions.at( cameraId )->capture( m_requests.at( cameraId ).get() ) };
                if( result == 0 )
                    REPORT_ERROR( "Capture failed!" );

                Argus::UniqueObj< EGLStream::Frame > frame{ m_iFrameConsumers.at( cameraId )->acquireFrame() };
                EGLStream::IFrame * iFrame{ Argus::interface_cast< EGLStream::IFrame >( frame ) };
                if( not iFrame )
                {
                    std::cout << "Failed to acquire frame! " << cameraId << std::endl;
                } else
                {
                    //                std::cout << cameraId << " " << iFrame->getNumber() << " " << iFrame->getTime() << std::endl;
                    // record
                    {
                        EGLStream::IImageJPEG * iJPEG{ Argus::interface_cast< EGLStream::IImageJPEG >( iFrame->getImage() ) };
                        if( iJPEG )
                        {
                            const auto file{ m_recordPath + "/" + std::to_string( cameraId ) + "/" + std::to_string( m_framesCounter ) + ".jpg" };
                            if( iJPEG->writeJPEG( file.c_str() ) != Argus::STATUS_OK )
                            {
                                std::cout << "Failed to write JPEG: " << file << std::endl;
                            }
                        }

                        m_doCapture = false;
                    }
                }

            } // pragma

Thanks.

Also i tried std::thread and join gives same result. Detach throws lost frames with Argus errors.
So it looks like Argus locks some acquire resource.

You may measure time waiting for frame from each sensor and time for saving to file.
What gives using gstreamer (assuming your sensor provides 720p10, be sure you have disk room for 600 jpeg compressed frames) ?

sudo jetson_clocks

gst-launch-1.0 -ev \
 nvarguscamerasrc sensor-id=0 num-buffers=100 ! 'video/x-raw(memory:NVMM),format=NV12,width=1280,height=720,framerate=10/1' ! nvjpegenc ! queue ! multifilesink location=cam0_frame_%03d.jpg \
 nvarguscamerasrc sensor-id=1 num-buffers=100 ! 'video/x-raw(memory:NVMM),format=NV12,width=1280,height=720,framerate=10/1' ! nvjpegenc ! queue ! multifilesink location=cam1_frame_%03d.jpg \
 nvarguscamerasrc sensor-id=2 num-buffers=100 ! 'video/x-raw(memory:NVMM),format=NV12,width=1280,height=720,framerate=10/1' ! nvjpegenc ! queue ! multifilesink location=cam2_frame_%03d.jpg \
 nvarguscamerasrc sensor-id=3 num-buffers=100 ! 'video/x-raw(memory:NVMM),format=NV12,width=1280,height=720,framerate=10/1' ! nvjpegenc ! queue ! multifilesink location=cam3_frame_%03d.jpg \
 nvarguscamerasrc sensor-id=4 num-buffers=100 ! 'video/x-raw(memory:NVMM),format=NV12,width=1280,height=720,framerate=10/1' ! nvjpegenc ! queue ! multifilesink location=cam4_frame_%03d.jpg \
 nvarguscamerasrc sensor-id=5 num-buffers=100 ! 'video/x-raw(memory:NVMM),format=NV12,width=1280,height=720,framerate=10/1' ! nvjpegenc ! queue ! multifilesink location=cam5_frame_%03d.jpg

Thanks.

Gst way shortest than cpp )

Images written, but how i can check timestamp?

In this case no metadata inside jpeg, gst does not log info.

For this topic, you would just check the 6 frames with same frame number.

I’d suggest to open another topic for timestamps.

1 Like

I made new topic: Gstreamer jpeg timestamp or metadata

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.