pip3 install numpy
始终出现连接超时错误,无法安装,采用国内镜像文件进行安装。
错误说明:
requests.exceptions.HTTPError: 404 Client Error: Not Found for url: https://pypi.org/simple/requirements-txt/
解决方法:
pip3 install --index https://pypi.mirrors.ustc.edu.cn/simple/ numpy
报错如下:
Cache entry deserialization failed, entry ignored
解决方法:
python -m pip install --upgrade pip #未解决,出现连接超时
pip install --upgrade pip #未解决,出现连接超时
pip install --index https://pypi.mirrors.ustc.edu.cn/simple/ --upgrade pip #解决
代码如下:
cv2.destroyWindows()
报错如下
cv2.destroyWindows()
AttributeError: module 'cv2.cv2' has no attribute 'destroyWindows'
解决如下:
cv2.destroyAllWindows()
def write_video(output_path = "./testData/output.mp4"):
#open the video
vid = cv2.VideoCapture('./testData/laneVideo1.mp4')
# open the camera
# capture = cv2.VideoCapture(0)
if not vid.isOpened():
raise IOError("couldn't open the video")
video_FourCC_ori = int(vid.get(cv2.CAP_PROP_FOURCC))
video_fourcc_mjpg = cv2.VideoWriter_fourcc(*"MJPG")
video_FourCC = cv2.VideoWriter_fourcc(*"mp4v")
video_fps = vid.get(cv2.CAP_PROP_FPS)
video_size = (int(vid.get(cv2.CAP_PROP_FRAME_WIDTH)),int(vid.get(cv2.CAP_PROP_FRAME_HEIGHT)))
isOutput = True if output_path != "" else False
if isOutput:
out = cv2.VideoWriter(output_path, video_Fourcc, video_fps, video_size)
while True:
ret, frame = vid.read()
cv2.imshow("video",frame)
out.write(frame)
key = cv2.waitKey(50)
if key == ord('q'):
break
out.release()
vid.release()
cv2.destroyAllWindows()
存储格式一:
video_FourCC_ori = int(vid.get(cv2.CAP_PROP_FOURCC))
报错如下:
Could not find encoder for codec id 27: Encoder not found
此时无法生成视频文件
存储格式二
video_fourcc_mjpg = cv2.VideoWriter_fourcc(*"MJPG")
报错如下:
OpenCV: FFMPEG: tag 0x47504a4d/'MJPG' is not supported with codec id 7 and format 'mp4 / MP4 (MPEG-4 Part 14)'
OpenCV: FFMPEG: fallback to use tag 0x7634706d/'mp4v'
此时可以生成视频文件,且能打开视频文件,但运行时出现错误
存储格式三
video_FourCC = cv2.VideoWriter_fourcc(*"mp4v")
此时能正常生成文件,问题解决。
TODO List
W0407 11:42:31.970886 7783 warnings.py:99] /home/df/anaconda3/envs/tf-cpu-cp36/lib/python3.6/site-packages/tensorflow/python/framework/dtypes.py:495: FutureWarning: Passing (type, 1) or '1type' as a synonym of type is deprecated; in a future version of numpy, it will be understood as (type, (1,)) / '(1,)type'.
_np_qint16 = np.dtype([("qint16", np.int16, 1)])
W0407 11:42:31.971002 7783 warnings.py:99] /home/df/anaconda3/envs/tf-cpu-cp36/lib/python3.6/site-packages/tensorflow/python/framework/dtypes.py:496: FutureWarning: Passing (type, 1) or '1type' as a synonym of type is deprecated; in a future version of numpy, it will be understood as (type, (1,)) / '(1,)type'.
_np_quint16 = np.dtype([("quint16", np.uint16, 1)])
W0407 11:42:31.971152 7783 warnings.py:99] /home/df/anaconda3/envs/tf-cpu-cp36/lib/python3.6/site-packages/tensorflow/python/framework/dtypes.py:497: FutureWarning: Passing (type, 1) or '1type' as a synonym of type is deprecated; in a future version of numpy, it will be understood as (type, (1,)) / '(1,)type'.
_np_qint32 = np.dtype([("qint32", np.int32, 1)])
W0407 11:42:31.971256 7783 warnings.py:99] /home/df/anaconda3/envs/tf-cpu-cp36/lib/python3.6/site-packages/tensorflow/python/framework/dtypes.py:502: FutureWarning: Passing (type, 1) or '1type' as a synonym of type is deprecated; in a future version of numpy, it will be understood as (type, (1,)) / '(1,)type'.
np_resource = np.dtype([("resource", np.ubyte, 1)])
import numpy as np
np.__version__
输出
1.18.2
pip uninstall numpy
pip install numpy==1.16.0