简体   繁体   English

如何检查openCV-Python使用的默认链接编解码器?

[英]How to check the default linked codec used by openCV-Python?

I just came into the world of openCV and python, and I'm having a strange issue with opening the video stream. 我刚进入openCV和python的世界,而在打开视频流时遇到了一个奇怪的问题。 This is the code that I'm using: 这是我正在使用的代码:

import numpy
import cv2

cap = cv2.VideoCapture('SampleVideo.mp4')
print(cap.isOpened())
while(cap.isOpened()):
    ret, frame = cap.read()
    gray = cv2.cvtColor(frame, cv2.COLOR_BGR2GRAY)
    cv2.imshow('frame',gray)
    if cv2.waitKey(1) & 0xFF == ord('q'):
        break

cap.release()
cv2.destroyAllWindows()

This code can successfully open the video stream when i run it in terminal(windows command line) but not in Pycharm. 当我在终端(Windows命令行)中运行但不在Pycharm中运行时,此代码可以成功打开视频流。 This is the result of the run in Pycharm: 这是在Pycharm中运行的结果:

False

Process finished with exit code 0 流程结束,退出代码为0

Any help would be appreciated. 任何帮助,将不胜感激。 Thank you all! 谢谢你们!

Codec: FFmpeg. 编解码器:FFmpeg。 OS: Windows 8.1. 操作系统:Windows 8.1。 Python: 3.5.2. 的Python:3.5.2。 OpenCV: 3.1 OpenCV的:3.1

Update Sep.27: 9月27日更新:

I noticed that the code runs successfully in IDLE, but not in PyCharm. 我注意到该代码在IDLE中成功运行,但在PyCharm中未成功运行。 Now I'm really confused. 现在我真的很困惑。

I can also confirm that imread and imwrite works properly in PyCharm. 我还可以确认impy和imwrite在PyCharm中可以正常工作。 So maybe it is the Codec that is not working? 因此,也许是编解码器无法正常工作? How to check my codec in OpenCV? 如何在OpenCV中检查我的编解码器?

Update Sep.29: 9月29日更新:

Now I think I've ruled out the possibility that the terminal and PyCharm are using different interpreter. 现在我想我已经排除了终端和PyCharm使用不同的解释器的可能性。 I really think it's somehow that the default codec is not linked in the PyCharm environment. 我真的认为在PyCharm环境中未链接默认编解码器是有原因的。 How do I check my default system codec either in OpenCV or Python? 如何在OpenCV或Python中检查默认系统编解码器?

The problem is solved. 问题已经解决了。

I solved it by purging everything, Pycharm, Python and all the packages. 我通过清除所有内容,Pycharm,Python和所有软件包来解决它。 So obviously this issue came from some sort of dependency mess-up. 因此,显然,此问题来自某种依赖性混乱。 Not really sure what it is, but purging is the way to go people. 不确定是什么,但是清除是去人的方法。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM