Visionworks Framesource slowdown

Hi Matt,
With your binary we can observe the issue. We checked nvvidconv and gstnvvideosink and both update in 30fps(updates every 33ms).

Have you checked if source->fetch() is called in 30fps in the app?

The source->fetch() and render->putImage(frame) are both called in the same loop and the timers are used.

I’ve made a modified version of the sample_player that just puts a frame on the screen rather than running any tracking. It opens v4l2 /dev/video0 using YUV with 1280x720 at 30fps.

/*
# Copyright (c) 2014-2016, NVIDIA CORPORATION. All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions
# are met:
#  * Redistributions of source code must retain the above copyright
#    notice, this list of conditions and the following disclaimer.
#  * Redistributions in binary form must reproduce the above copyright
#    notice, this list of conditions and the following disclaimer in the
#    documentation and/or other materials provided with the distribution.
#  * Neither the name of NVIDIA CORPORATION nor the names of its
#    contributors may be used to endorse or promote products derived
#    from this software without specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ``AS IS'' AND ANY
# EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
# PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR
# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
# PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
# OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/

#include <iostream>
#include <sstream>
#include <iomanip>
#include <memory>

#include <VX/vx.h>
#include <NVX/nvx_timer.hpp>

#include "NVX/Application.hpp"
#include "OVX/FrameSourceOVX.hpp"
#include "OVXFrameSourceTest.hpp"
#include "OVX/RenderOVX.hpp"
#include "NVX/SyncTimer.hpp"
#include "OVX/UtilityOVX.hpp"

struct EventData
{
    EventData(): alive(true), pause(false) {}

    bool alive;
    bool pause;
};

static void keyboardEventCallback(void* context, vx_char key, vx_uint32 /*x*/, vx_uint32 /*y*/)
{
    EventData* eventData = static_cast<EventData*>(context);
    if (key == 27) // escape
    {
        eventData->alive = false;
    }
    else if (key == 32)
    {
        eventData->pause = !eventData->pause;
    }
}

//
// main - Application entry point
//

int main(int argc, char** argv)
{
    try
    {
        nvxio::Application &app = nvxio::Application::get();
        ovxio::printVersionInfo();

        //
        // Parse command line arguments
        //

        //std::string input = app.findSampleFilePath("cars.mp4");

        app.setDescription("This sample plays a video from video-file or camera");
       // app.addOption('s', "source", "Input URI", nvxio::OptionHandler::string(&input));
        app.init(argc, argv);

        //
        // Create OpenVX context
        //

        ovxio::ContextGuard context;

        //
        // Messages generated by the OpenVX framework will be processed by ovxio::stdoutLogCallback
        //

        vxRegisterLogCallback(context, &ovxio::stdoutLogCallback, vx_false_e);

        //
        // Create a Frame Source
        //

        std::string input = "YUV";
    
        std::unique_ptr<ovxio::FrameSource> source(ovxio::createTestFrameSource(context, input));
        if (!source || !source->open())
        {
            std::cerr << "Error: Can't open source URI " << input << std::endl;
            return nvxio::Application::APP_EXIT_CODE_NO_RESOURCE;
        }
        ovxio::FrameSource::Parameters config = source->getConfiguration();

        //
        // Create a Render
        //

        std::unique_ptr<ovxio::Render> render(ovxio::createDefaultRender(
                    context, "Player Sample", config.frameWidth, config.frameHeight));
        if (!render)
        {
            std::cout << "Error: Cannot open default render!" << std::endl;
            return nvxio::Application::APP_EXIT_CODE_NO_RENDER;
        }

        EventData eventData;
        render->setOnKeyboardEventCallback(keyboardEventCallback, &eventData);

        vx_image frame = vxCreateImage(context, config.frameWidth,
                                       config.frameHeight, config.format);
        NVXIO_CHECK_REFERENCE(frame);

        ovxio::Render::TextBoxStyle style = {{255,255,255,255}, {0,0,0,127}, {10,10}};

        std::unique_ptr<nvxio::SyncTimer> syncTimer = nvxio::createSyncTimer();
        syncTimer->arm(1. / app.getFPSLimit());

        nvx::Timer totalTimer;
        totalTimer.tic();
        while(eventData.alive)
        {
            ovxio::FrameSource::FrameStatus status = ovxio::FrameSource::OK;
            if (!eventData.pause)
            {
                status = source->fetch(frame);
            }

            switch(status)
            {
            case ovxio::FrameSource::OK:
            {
                double total_ms = totalTimer.toc();

                std::cout << "NO PROCESSING" << std::endl;
                std::cout << "Display Time : " << total_ms << " ms" << std::endl << std::endl;

                syncTimer->synchronize();

                total_ms = totalTimer.toc();
                totalTimer.tic();

                std::ostringstream txt;
                txt << std::fixed << std::setprecision(1);

                txt << "Source size: " << config.frameWidth << 'x' << config.frameHeight << std::endl;
                txt << "Algorithm: " << "No Processing" << std::endl;
                txt << "Display: " << total_ms  << " ms / " << 1000.0 / total_ms << " FPS" << std::endl;

                txt << std::setprecision(6);
                txt.unsetf(std::ios_base::floatfield);

                txt << "LIMITED TO " << app.getFPSLimit() << " FPS FOR DISPLAY" << std::endl;
                txt << "Space - pause/resume" << std::endl;
                txt << "Esc - close the demo";

                render->putImage(frame);
                render->putTextViewport(txt.str(), style);

                if (!render->flush())
                    eventData.alive = false;
            } break;
            case ovxio::FrameSource::TIMEOUT:
            {
                // Do nothing
            } break;
            case ovxio::FrameSource::CLOSED:
            {
                // Reopen
                if (!source->open())
                {
                    std::cerr << "Error: Failed to reopen the source" << std::endl;
                    eventData.alive = false;
                }
            } break;
            }
        }

        //
        // Release all objects
        //
        vxReleaseImage(&frame);
    }
    catch (const std::exception& e)
    {
        std::cerr << "Error: " << e.what() << std::endl;
        return nvxio::Application::APP_EXIT_CODE_ERROR;
    }

    return nvxio::Application::APP_EXIT_CODE_SUCCESS;
}

nvx_sample_player.zip (220 KB)

Hi MattTS, we shall have this fixed in next release.

Hi, Dear MattTS, DaneLLL

Have you solved the problem ? I have met the same problem . I used IPC camera, and used rtspsrc → decodebin → nvvidconv → nvvdieosink , then I set the property of “display” and “stream” and got the frame from eglframe. My frame width = 1920, height = 1080 , after 4 seconds , the video slowdown, and the display rate remain high . If it is a bug ?

I used the same gstreamer pipeline in TX1, it wouldn’t have this problem.

Thanks,

Hi ClancyLian,

I experimented a lot more with the Visual Profiler and some gstreamer debugging software but I couldn’t find a fix unfortunately. The nearest I came was when I was using the profiler and it lost connection and then the program kept running without the video slowdown occurring. I couldn’t recreate this reliably though.

I just noticed there’s a new release of Jetpack with new BSP, drivers etc. I’ve yet to try this!

Hi, MattTS

I will try it on JetPack 3.1 .

Thanks,

I tried on 3.1 and as far as I can tell the problem has been fixed. I’ll be interested to see if ClancyLian can conform this.

Hi, MattTS

I am glad to see you have solved problem on JetPack 3.1. Today, I have tried it, and I’m very excited to see my problem also have been fixed.

Thanks for your help and DaneLLL’s help.