imwrite python不保存图像[Mac]

时间:2016-04-14 03:03:44

标签: macos python-3.x opencv3.0

我正在尝试从视频播放中保存帧。代码运行没有任何错误,但是,我无法在我的文件夹中找到我保存的图像。下面是我写的脚本。我在mac上使用python版本3.5和OpenCV3。任何帮助是极大的赞赏。提前谢谢。

import sys
sys.path.append('/Applications/OpenCV3/build/lib/python3')

import cv2
import numpy as np
import matplotlib.pyplot as plt

i = 0
Mx = cv2.VideoCapture('LB.mp4')
if Mx.isOpened()== True:
    print('',Mx.isOpened())
else:
    print('',Mx.isOpened())

while(Mx.isOpened()):
    print('i = ', i)
    ret, frame = Mx.read()
    cv2.imshow('Original',frame)
    cv2.waitKey(50)
    i += 1
    if i == 10:
        gray = cv2.cvtColor(frame, cv2.COLOR_BGR2GRAY)
        cv2.imwrite = ('Missile.bmp', gray)
        print('Imaged saved at i = ', i)
        break

print('End of While Loop')
Mx.release()
cv2.destroyAllWindows()

0 个答案:

没有答案