我使用opencv在beaglebone black中获得部分绿色图像。我该怎么办?

我使用opencv在beaglebone black中获得部分绿色图像。我该怎么办?,opencv,beagleboneblack,opencv-python,Opencv,Beagleboneblack,Opencv Python,我正在使用Beaglebone Black Rev-C。我的目标是捕获视频并运行对象检测。为了确保视频捕获正确,我将帧保存为图像,并将其保存在视频文件中。我不打算连接视频输出显示器。因此,我没有使用cv2.imshow()。框架不完整,部分为绿色 其中一帧的输出: 使用v4l2 ctl--all获得的摄像机信息: Driver Info (not using libv4l2): Driver name : uvcvideo Card type : U

我正在使用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, Top 0, Width 320, Height 240
        Pixel Aspect: 1/1
Selection: crop_default, Left 0, Top 0, Width 320, Height 240
Selection: crop_bounds, Left 0, Top 0, Width 320, 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") 
导入cv2
#创建要读取的对象
#从照相机
视频=cv2.VideoCapture(0,cv2.CAP_V4L)
#我们需要检查一下摄像机
#是否以前打开过
如果(video.isOpened()==False):
打印(“读取视频文件时出错”)
#我们需要制定决议。
#所以,将它们从浮点转换为整数。
#帧宽度=int(video.get(3))
#帧高度=int(视频获取(4))
大小=(160120)
#下面的VideoWriter对象将创建
#上面定义的输出的帧
#存储在“filename.avi”文件中。
结果=cv2.VideoWriter('filename.avi',
cv2.VideoWriter_fourcc(*“YUYV”),
1、尺寸
) 
计数=0
打印('开始')

while(count)我想我会在阅读每一帧后检查
frame.shape
。我还会尝试
cvtColor(…YUYV2BGR…
),这样我就可以编写一个普通的RGB视频而不是YUYV视频了。