Timeout connecting to output stream in adaptation of yuvJpeg example code

Hardware platform: Jetson Nano
Jetpack version: 4.6.1

The yuvJpeg example Argus code works correctly on my system. However, after adapting that code for my application, my video camera consumer thread (using C++ std::thread) times out while attempting to connect to the output stream. The following code snippet represents the beginning portion of my video camera consumer thread:

    void videoCameraThread(Argus::OutputStream* outputStream) {

        static const int Y  = 0;
        static const int UV = 1;

        const std::string threadName          = "Video camera";
        const std::string capturedVideoFrames = "Captured video frames";

        threads::enqueueLoggerMessage(threadName, "Starting video camera thread");

        // Add a metric for this thread that will be reported by the thread performance monitor.
        threads::addMetric(capturedVideoFrames);

        // Create the frame consumer.
        Argus::UniqueObj<EGLStream::FrameConsumer> frameConsumer = Argus::UniqueObj<EGLStream::FrameConsumer>(EGLStream::FrameConsumer::create(outputStream));
        auto *iFrameConsumer = Argus::interface_cast<EGLStream::IFrameConsumer>(frameConsumer);

        // Connect to the output stream.
        auto *iStream = Argus::interface_cast<Argus::IEGLOutputStream>(outputStream);
        Argus::Size2D<uint32_t> resolution = iStream->getResolution();
        std::ostringstream oss;
        oss << "Connecting to (" << resolution.width() << " x " << resolution.height() << ") output stream...";
        threads::enqueueLoggerMessage(threadName, oss.str());
        Argus::Status connectionStatus = iStream->waitUntilConnected(5 * helpers::NANOSECONDS_PER_SECOND);
        EXCEPTION_IF_NOT_EQUAL(connectionStatus, Argus::STATUS_OK, "Failed to connect to output stream.")
        threads::enqueueLoggerMessage(threadName, "Connected to output stream.");

The call to method waitUntilConnected() fails.

My program’s output is:

Executing Argus Sample: framosIMX662Demo
Thu Jul 27 13:14:29 2023: main: Configuring camera producer using Argus version 0.98.3 (multi-process)
Thu Jul 27 13:14:29 2023: main: Done configuring the Argus camera.
Thu Jul 27 13:14:29 2023: Video camera: Starting video camera thread
Thu Jul 27 13:14:29 2023: Video camera: Connecting to (1920 x 1080) output stream...
Thu Jul 27 13:14:30 2023: main: Press any key to stop...
terminate called after throwing an instance of 'std::runtime_error'
  what():  Failed to connect to output stream.

The outputStream argument to the thread is created by my program’s main() function, using code that is nearly identical to the code in function execute() in the yuvJpeg example.

There appears to be some sort of order-of-operations problem that is not obvious to me. The fundamental difference between my application and the yuvJpeg application is I create my camera consumer thread after creating the output stream, whereas the yuvJpeg application creates its camera consumer thread during the process of creating the output stream.

Has anyone else had similar problems adapting the yuvJpeg example code to their application?

Thanks!

Did you start capture by the repeat() function?

I was able to resolve this problem by copying the yuvJpeg example code to my application and slowly modifying the code until it fit into my architecture. Please consider this issue closed.

1 Like

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