simewu / video-power-log-to-csv

Convert a video of a power monitor into a CSV file

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Convert a power log video into a CSV file

Convert a video of a power monitor into a CSV file containing a frame per row and the following columns:

  • Frame number
  • Timestamp (seconds)
  • Voltage (V)
  • Current (A)
  • Power (W)
  • Power Factor (%)
  • Total Power Usage (kWh)
  • Oneshot Power Usage (kWh)
  • Total Electricity Bill ($)
  • Oneshot Electricity Bill ($)

Requirements

  • A ZHURUI PR10 Power Recorder which can be found here
    • Note: To use a different device/user interface, modify the regular expression in Step 3
  • A camera to capture a video of the screen
  • A 64-bit Windows machine
  • Install Python3 and Tesseract (64-bit) (from here)

Usage

  • Record the video and save it as video.mp4
  • Double click on step1_video_to_frames.bat to generate the frames folder containing each frame in .jpg format
  • Double click on step2_frames_to_readtext.bat to convert the frames into readtext .txt files using Tesseract
  • Double click on step3_readtext_to_csv.bat to process the text files using a regular expression, generating output.csv
    • The script will skip invalid frames
  • Double click on step4_cleanup_output_file.bat to the top and bottom X percentile of the data, generating finalOutput.csv
    • Repeat this step, tweaking percentileAmount to be as low as possible to maintain the data quality (by looking at the minimum and maximum values after running the script), and columnsToInclude which enumerated the columns in the data, and only considers those marked as "1".
  • You will have now generated finalOutput.csv.

About

Convert a video of a power monitor into a CSV file


Languages

Language:Python 90.5%Language:Batchfile 9.5%