问题描述
我正在使用Beaglebone Black Rev-C。我的目标是捕获视频并运行对象检测。为了确保视频捕获正确,我将帧另存为图像并将其保存在视频文件中。我不打算连接视频输出显示器。因此,我没有使用过cv2.imshow()
。框架不完整,部分为绿色。
使用v4l2-ctl --all
获得的相机信息:
Driver Info (not using libv4l2):
Driver name : uvcvideo
Card type : USB2.0 Camera: USB2.0 Camera
Bus info : usb-musb-hdrc.1-1
Driver version: 4.19.94
Capabilities : 0x84A00001
Video Capture
Metadata Capture
Streaming
Extended Pix Format
Device Capabilities
Device Caps : 0x04200001
Video Capture
Streaming
Extended Pix Format
Priority: 2
Video input : 0 (Camera 1: ok)
Format Video Capture:
Width/Height : 320/240
Pixel Format : 'YUYV'
Field : None
Bytes per Line : 640
Size Image : 153600
Colorspace : sRGB
Transfer Function : Default (maps to sRGB)
ycbcr/HSV Encoding: Default (maps to ITU-R 601)
Quantization : Default (maps to Limited Range)
Flags :
Crop Capability Video Capture:
Bounds : Left 0,Top 0,Width 320,Height 240
Default : Left 0,Height 240
Pixel Aspect: 1/1
Selection: crop_default,Left 0,Height 240
Selection: crop_bounds,Height 240
Streaming Parameters Video Capture:
Capabilities : timeperframe
Frames per second: 30.000 (30/1)
Read buffers : 0
brightness 0x00980900 (int) : min=-127 max=127 step=1 de fault=0 value=0
contrast 0x00980901 (int) : min=0 max=127 step=1 defau lt=64 value=64
saturation 0x00980902 (int) : min=0 max=255 step=1 defau lt=64 value=64
hue 0x00980903 (int) : min=-16000 max=16000 step= 1 default=0 value=0
white_balance_temperature_auto 0x0098090c (bool) : default=1 value=1
gamma 0x00980910 (int) : min=16 max=500 step=1 defa ult=100 value=100
power_line_frequency 0x00980918 (menu) : min=0 max=2 default=1 valu e=1
white_balance_temperature 0x0098091a (int) : min=2800 max=6500 step=1 d efault=5200 value=5200 flags=inactive
sharpness 0x0098091b (int) : min=0 max=10 step=1 defaul t=6 value=6
exposure_auto 0x009a0901 (menu) : min=0 max=3 default=3 valu e=3
exposure_absolute 0x009a0902 (int) : min=1 max=2500 step=1 defa ult=625 value=625 flags=inactive
exposure_auto_priority 0x009a0903 (bool) : default=0 value=1
我使用的代码是:
import cv2
# Create an object to read
# from camera
video = cv2.VideoCapture(0,cv2.CAP_V4L)
# We need to check if camera
# is opened prevIoUsly or not
if (video.isOpened() == False):
print("Error reading video file")
# We need to set resolutions.
# so,convert them from float to integer.
#frame_width = int(video.get(3))
#frame_height = int(video.get(4))
size = (160,120)
# Below VideoWriter object will create
# a frame of above defined The output
# is stored in 'filename.avi' file.
result = cv2.VideoWriter('filename.avi',cv2.VideoWriter_fourcc(*'YUYV'),1,size
)
count=0
print('Starting')
while(count<50):
ret,frame = video.read()
#ret,frame = video.read()
if ret == True:
# Write the frame into the file 'filename.avi'
result.write(frame)
count=count+1
cv2.imwrite('frames/frame'+str(count)+'.bmp',frame)
# Press S on keyboard
# to stop the process
if cv2.waitKey(1) & 0xFF == ord('s'):
break
# Break the loop
else:
break
# When everything done,release
# the video capture and video
# write objects
video.release()
result.release()
# Closes all the frames
cv2.destroyAllWindows()
print("The video was successfully saved")
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)