9-4 Capture and Display Example
Welcome to the hands-on development phase! Before we start writing a single line of code, let's take a look at the final result of this chapter.
As shown in the figure, our goal today is very clear: we are going to build a "canvas" in the Qt Graphical User Interface ( GUI ), and by calling the NexVDO SDK, we will render the video received from an external capture card ( such as the SC710 capture card ) onto this window in real-time and smoothly.
Does it sound complicated? Don't worry, the NexVDO SDK perfectly encapsulates the extremely complex underlying video processing. To achieve the above result, we only need to learn 4 core APIs!

© Blender Foundation | Big Buck Bunny | CC BY 3.0
Understanding the Core APIs - Device Lifecycle
Before formally starting to write code, we must first understand the lifecycle of the NexVDO SDK. Operating this SDK is actually like driving a car; you must strictly follow the calling order of the APIs. Our goal today is to create a device through these APIs and successfully display the video on the UI.

1. QCAP_CREATE:Responsible for "creating" and initializing the video capture device.
2. QCAP_RUN:Responsible for "starting" the device, allowing the capture card to operate and render the video onto the screen.
3. QCAP_STOP:Responsible for "stopping" the device's operation.
4. QCAP_DESTROY:Responsible for "releasing and destroying" the device resources.
⚠️This is extremely important: Before closing the project, the user must call this API to release the device to avoid memory leaks!

The subsequent three APIs ( QCAP_RUN, QCAP_STOP, QCAP_DESTROY ) only require passing the device control handle ( pDevice ) that we obtained during QCAP_CREATE.
Now that we understand the lifecycle, let's break down the parameters of each API in detail:
QCAP_CREATE
This is the most complex but also the most critical API, responsible for binding our software window to the underlying hardware.
⚠️Important Preparation Before Development: Don't forget to install the capture card driver! For the program to successfully find and bind your capture card (e.g., SC710) via QCAP_CREATE, the operating system must first "recognize" it! Please ensure that the corresponding capture card driver is properly installed on your PC or development board.
➤ Where can I find the driver? It is recommended to contact official technical support directly. Only after clearing the underlying hardware path can our programming magic be successfully cast!
Once the driver is ready, let's look at the important parameters included in this API :

QCAP_RUN、QCAP_STOP、QCAP_DESTROY
Once you successfully create a device using QCAP_CREATE, the subsequent start, stop, and release actions become extremely simple. The structure of these three APIs is exactly the same; they all require only a single parameter to be passed in:

Please directly open the template project you built in the previous chapter, follow us to drag out the canvas on the UI, and call the 4 capture APIs to successfully present real-world video on your UI!
Writing the Core Code
It's finally time to write some code! Please open mainwindow.h and mainwindow.cpp to complete the final pieces of the puzzle:
Including Header Files and Declaring Variables ( mainwindow.h )
Include the necessary header files #include "qcap.h" and #include "qcap.common.h", and declare a variable in the public section to store the device control code: PVOID m_pDevice = NULL; .
Include the essential header files #include "qcap.h" and #include "qcap.common.h", and declare a variable in the public section to store the device control handle: PVOID m_pDevice = NULL;.


Initialize and Start Capture ( mainwindow.cpp )
In the constructor of MainWindow, add the following four APIs:
• Use QCAP_CREATE to open the device and bind it to the PreviewWindow we just created.
➤ Performance Optimization Secret: Use QCAP_SET_VIDEO_DEFAULT_OUTPUT_FORMAT to specify the output color space as NV12. Since our underlying hardware platform is NVIDIA, the NV12 format allows the NVIDIA platform to maximize its video processing performance!
• Use QCAP_SET_VIDEO_INPUT to set it to automatically detect the input signal ( QCAP_INPUT_TYPE_AUTO ).
• Finally, call QCAP_RUN(m_pDevice); to start the device.

Safely Close the Device ( mainwindow.cpp )
In the destructor ~MainWindow(), be sure to add a condition: if the device is not empty, call QCAP_STOP and QCAP_DESTROY in sequence, and set the variable to NULL.

After completing the above steps, click "Build and RUN", and you will be able to see the smooth captured video in the window! Congratulations on completing your first NexVDO SDK project!

© Blender Foundation | Big Buck Bunny | CC BY 3.0
Hands-on Troubleshooting Guide
During the development of video applications, having no video output is often the most frustrating part. If you didn't see the video in the previous step, please follow the steps below to verify if the device is functioning properly:
Check Hardware Detection ( lspci )
Confirm whether the hardware device is connected correctly. Sometimes the problem lies at the lowest hardware level, so we must first confirm whether the system has correctly detected the capture card:
1. Right-click on the system desktop and select "Open in Terminal".
2. Enter the command lspci in the terminal. This command will list all PCI devices on the system.
3. Look closely at the output list. Users should find device information containing "0710" in the list ( displayed as Multimedia controller: YUAN High-Tech Development Co., Ltd. Device 0710 ). This means the hardware has been successfully recognized by the system.


Check Signal Source ( v4l2-ctl )
After confirming the hardware exists, the next step is to confirm "whether there is a signal connected to the device":
1. In the terminal again, please enter the command v4l2-ctl -DVI --get-parm to check the signal status.
➤ For the installation of v4l2 related tools, you can review: Chapter 2-3 Installing Jetson Component Environment
2. This command will return detailed signal information. Please pay special attention to check if the current Resolution ( Width/Height ) and Framerate ( Frames per second ) are correct. For example, if a 1080p60 signal source is connected, you will see Width/Height displayed as 1920/1080, and Frames per second displayed as 60.000.

Resolve Program Crash (fcCacheChains[i] == NULL failed)

If you encounter the error message "Assertion fcCacheChains[i] == NULL' failed**" causing the program to crash while running, don't worry! Please go to the left menu in Qt Creator: "Projects ➔ Run ➔ Environment", click Add, and set the environment variable QCAP_FONT_DEFERRED_LOAD=0 to successfully resolve it!
