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 8 Next »

main.py

main.py is the main program that includes functions that call functions from other files. Using file names in other module folders, main.py imports functions from those files, and those functions can now be called anywhere in main.py. Each function written in main.py takes care of a different task.

callTrain() checks if the "targetAcquisition/yolov2_assets" path exists, then imports its module. callTrain() does not call any imported functions.

flightProgram() instantiates a video pipeline, video mediator, and frame capture. flightProgram() then feeds tent coordinates into pipeline, feeds the tent coordinates from pipeline into geolocation, retrieves GPS coordinates from geolocation, and sends these coordinates to the command module. This method calls imported functions decklinkSrcWorker(), pipelineMergeWorker(), targetAcquisitionWorker(), geolocation_locator_worker(), geolocation_output_worker, and flight_command_worker().

qrProgram() uses the webcam to detect and decode a QR code to return the string message that the QR contains. The qrProgram() function uses decklinkSrcWorker_taxi() to access a camera stream which provides frames from the camera, and these frames are then passed into qr_worker() as its parameter pipelineIn. qrProgram() calls imported methods decklinkSrcWorker_taxi() and qr_worker().

init_logger() initializes the logger with formatted date and time. This method does not call any imported functions.

taxiProgram() → ignore for now

showVideo() displays a user’s default webcam. This function calls imported methods from videoDisplayWorker.py and decklinkSrcWorker_taxi.py.

videoDisplayWorker.py

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.

  • No labels