Click here to Skip to main content
15,886,664 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Python
import cv2
import numpy as np

cameraCapture = cv2.VideoCapture('test_1.avi')

success, frame = cameraCapture.read()
while success:
    if cv2.waitKey(1) == 27:
        break
    cv2.imshow('Test camera', frame)
    
    success, frame = cameraCapture.read()
    milliseconds = cameraCapture.get(cv2.CAP_PROP_POS_MSEC)
    
    seconds = milliseconds//1000
    milliseconds = milliseconds%1000
    minutes = 0
    hours = 0
    if seconds >= 60:
        minutes = seconds//60
        seconds = seconds % 60

    if minutes >= 60:
        hours = minutes//60
        minutes = minutes % 60

    print(int(hours), int(minutes), int(seconds), int(milliseconds),a)

cv2.destroyAllWindows()
cameraCapture.release()

I want to print the time line of this video as well as the mean of this frame,for example like printf (0h 0m 2s 33m 34)

What I have tried:

C++
cv.cvtColor(image, gray, cv.COLOR_RGB2GRAY);
    Mat mat_mean, mat_stddev;
    meanStdDev(gray, mat_mean, mat_stddev);
    double a = mat_mean.at<double>(0, 0);
    double d = mat_stddev.at<double>(0, 0);

I once wanted to bring the C++ program code into the program, but I couldn't implement the call to the mean function. How can I change my program
Posted
Updated 27-May-21 21:45pm

Read Your Guide to the Python print to fully understand the options and power of the print function.

The russian Lenin wrote a book about "Knowledge is power" ;-)
 
Share this answer
 
In addition to Karsten's sugestion you can look at 7. Input and Output — Python 3.9.5 documentation[^].
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900