Skip to content

A method to extract code from qr codes in a video, output it to a live python editor, the terminal and a text file.

Notifications You must be signed in to change notification settings

txtatech/qr-vid

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

13 Commits
 
 
 
 
 
 

Repository files navigation

qr-vid

A method to extract code from qr codes in a video, output it to a live python editor, the terminal and a text file.

Version 0.0.02 Note:

Includes a toolset for creating structured code in text and JSON format for the initial code base and extracting validator code from a video's subtitles.

There is now a live python code editor for inspecting, editing and executing the extracted code.

Stable files are in qr-vid-rapid-steps.

There is a simplified GUI version of qr-vid here: https://github.com/txtatech/qr-vid-gui

QR-Vid

This Python script demonstrates how to decode QR codes from a video file and save the decoded data to a text file. It also prints the output to the terminal. It utilizes the cv2 (OpenCV) library for video processing and the pyzbar.pyzbar library for decoding QR codes.

Requirements

Before running the script, make sure you have the following libraries installed:

  • OpenCV (cv2)
  • pyzbar

You can install the required libraries using pip:

pip install opencv-python
pip install pyzbar

Usage

  1. Ensure you have a video file (qr-test.mkv in this example) containing QR codes.
  2. Place the Python script in the same directory as the video file.

Running the Script

The script reads the video file frame by frame, converts each frame to grayscale (optional, depending on the video), and decodes any QR codes present in the frame. The decoded data is then saved to a text file (qr-test-decoded.txt) for further processing or analysis.

To run the script, open a terminal or command prompt and navigate to the directory containing the Python script and the video file. Then, execute the following command:

python qr-vid-decode-v1.py

or

python qr-vid-decode-v2.py

python qr-vid-decode-v1.py Prints to terminal only. python qr-vid-decode-v2.py Prints to terminal and outputs to a text file.

Output

As the script runs, it will display the frames of the video in a window named "Video" and print the decoded data for each QR code found in the frames. The decoded data will also be written to the qr-test-decoded.txt text file in the same directory as the script. The script also prints the decoded data to the terminal.

Exiting the Script

To exit the script, press the 'q' key while the "Video" window is active. The script will stop processing the video and close the window.

Note

  • If you encounter any issues or errors, please make sure you have the required libraries installed and that the video file exists in the specified location.

Adjusting Playback Speed:

If you want to slow down the video playback, you can increase the delay. For example, setting the delay to 100 milliseconds will slow down the video by a factor of 100: if cv2.waitKey(100) & 0xFF == ord('q'):. This will display each frame for approximately 100 milliseconds before moving on to the next frame.

Similarly, if you want to speed up the video playback, you can decrease the delay. For example, setting the delay to 10 microseconds will speed up the video by a factor of 0.01: if cv2.waitKey(10) & 0xFF == ord('q'):. Note that setting a very small delay may cause the video to appear choppy.

You can experiment with different delay values to find the playback speed that suits your needs. Keep in mind that if the delay is too small, it may become difficult to interact with the video using the 'q' key to exit the loop, as the program will not have enough time to process the key press.

Example Image

MIT License

Copyright (c) 2023

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

About

A method to extract code from qr codes in a video, output it to a live python editor, the terminal and a text file.

Topics

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages