Skip to end of metadata
Go to start of metadata

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 4 Current »

videoDisplayWorker.py

The purpose of the videoDisplay module is to simply use OpenCV methods to open a new window and display a user’s webcam to that window. This module also uses the decklinksrc module to retrieve and display frames.

Video display in python uses OpenCV, which is a library of programming functions that allow various functionalities in real-time computer vision. This includes video and image processing, object detection, tracking, and many more. In the videoDisplayWorker.py file, the OpenCV library is imported and used to display the user’s default webcam.

In decklinkSrcWorker_taxi.py, a DeckLinkSRC object is created, and continuously grabs frames from the device’s webcam. Since all parameters in python are pass by reference, the piplineOut parameter is constantly updated to a new frame using the put() function. In showVideo, both functions videoDisplay() and decklinkSrcWorker() are run in a list of parallel processes. Since both functions run in parallel and the pipelineOut variable is constantly updated, this variable can be passed into videoDisplay() as a parameter for every new frame taken from the decklink webcam.

In videoDisplayWorker.py, the videoDisplay() function takes in the frame captured by dekclinkSrcWorker_taxi() as a parameter (pipelineIn). In a continuous loop, the videoDisplay() function uses the cv2.imshow() method which creates as new window and sets the pipelineIn as the current frame. In the program, this displays each frame at a high speed in a loop. Altogether, these output a new window showing the user’s webcam video. Note that there is an if statement that closes the window when ‘q’ is clicked on the user’s keyboard. This closes the window but does not disactivate the user’s webcam (webcam light remains on). To completely end the program, click on the garbage can icon to the right of the terminal. This is highlighted in yellow below.

As mentioned before, main.py runs decklinkSrcWorker_taxi() and videoDisplay() functions at the same time. The frame acquired by decklinkSrcWorker_taxi() is instantly passed into videoDisplay() and output to the screen. This is done continuously to create a full video stream. The high-speed frames that are acquired and output is what creates a functional webcam display. The flowchart below demonstrates the path of the showVideo() function in main.py.

  • No labels