我想同时输出一个视频的时间轴并且输出在这一帧的图片均值

我想在输出一个视频的时间轴的同时输出在这一帧的图片均值,下面是提取视频时间轴的程序

        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()

目前是有想用到mean函数来判断在这一帧里的图片的均值,比如

        image = imread(path_str, 1);
        cvtColor(image, gray, CV_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);
        cout << a << endl;
        cout << d << endl;

但是不太清楚如何将这一段转化为python的程序,image就是之前时间轴中的frame,那么Mat mat_mean函数在这里表达的是什么意思呢?如果想把这一段改写成python语句的话需要怎么修改呢?

阅读 907
撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进
推荐问题
宣传栏