Hi3516DV300的UVC功能测试

SDK: Hi3516CV500_SDK_V2.0.1.0

一、编译内核

使用Hi3516DV300的默认内核配置即可,不用进行修改,可通过menuconfig查看一下关键选项

$ cp arch/arm/configs/hi3516dv300_smp_defconfig .config
$ make ARCH=arm CROSS_COMPILE=arm-himix200-linux- uImage

二、编译模块

$ make ARCH=arm CROSS_COMPILE=arm-himix200-linux- modules

把libcomposite.ko和usb_f_uvc.ko拷贝到目标板上

三、编译uvc_app

进入uvc_app目录,make生成可执行文件,并拷贝到目标板上

sample/uvc_app$ make

四、测试

1、修改目标板/etc/profile,增加环境变量

export VID="0x12d1"
export PID="0x4321"
export MANUFACTURER="Huawei"
export PRODUCT="HiCamera"
export SERIALNUMBER="12345678"
export CamControl1=0xa
export CamControl2=0x0
export CamControl3=0x0
export ProcControl1=0x4f
export ProcControl2=0x14
export YUV="360p"
export MJPEG="360p 720p 1080p"
export H264="360p 720p 1080p "

2、加载模块

# insmod libcomposite.ko 
# insmod usb_f_uvc.ko 

3、把SDK提供的ConfigUVC.sh拷贝的目标板并运行

ConfigUVC.sh脚本:

#!/bin/sh

mount -t configfs none /sys/kernel/config/
cd /sys/kernel/config/usb_gadget/
mkdir camera
cd camera
echo $VID > idVendor
echo $PID > idProduct
mkdir strings/0x409
echo $MANUFACTURER > strings/0x409/manufacturer
echo $PRODUCT > strings/0x409/product
echo $SERIALNUMBER > strings/0x409/serialnumber

mkdir functions/uvc.usb0
cd functions/uvc.usb0
mkdir control/header/h/
echo "0x0110" > control/header/h/bcdUVC
echo "48000000" > control/header/h/dwClockFrequency
ln -s control/header/h/ control/class/fs/
ln -s control/header/h/ control/class/ss/


cat <<EOF> control/terminal/camera/default/bmControls
$CamControl1
$CamControl2
$CamControl3
EOF

cat <<EOF> control/processing/default/bmControls
$ProcControl1
$ProcControl2
EOF

#YUV
mkdir streaming/uncompressed/u/
for i in $YUV
do
    if [ $i = 360p ];then
        mkdir streaming/uncompressed/u/360p/                                     
	echo "333333" > streaming/uncompressed/u/360p/dwFrameInterval           
	echo "333333" > streaming/uncompressed/u/360p/dwDefaultFrameInterval           
	echo "55296000" > streaming/uncompressed/u/360p/dwMaxBitRate            
	echo "460800" > streaming/uncompressed/u/360p/dwMaxVideoFrameBufferSize  
	echo "55296000" > streaming/uncompressed/u/360p/dwMinBitRate     
	echo "360" > streaming/uncompressed/u/360p/wHeight                       
	echo "640" > streaming/uncompressed/u/360p/wWidth
    elif [ $i = 720p ];then
        mkdir streaming/uncompressed/u/720p/                                     
	echo "333333" > streaming/uncompressed/u/720p/dwFrameInterval           
	echo "333333" > streaming/uncompressed/u/720p/dwDefaultFrameInterval   
	echo "29491200" > streaming/uncompressed/u/720p/dwMaxBitRate             
	echo "1843200" > streaming/uncompressed/u/720p/dwMaxVideoFrameBufferSize
	echo "29491200" > streaming/uncompressed/u/720p/dwMinBitRate             
	echo "720" > streaming/uncompressed/u/720p/wHeight               
	echo "1280" > streaming/uncompressed/u/720p/wWidth
    elif [ $i = 1080p ];then
        mkdir streaming/uncompressed/u/1080p/                                    
	echo "333333" > streaming/uncompressed/u/1080p/dwFrameInterval           
	echo "333333" > streaming/uncompressed/u/1080p/dwDefaultFrameInterval
	echo "29491200" > streaming/uncompressed/u/1080p/dwMaxBitRate            
	echo "4147200" > streaming/uncompressed/u/1080p/dwMaxVideoFrameBufferSize
	echo "29491200" > streaming/uncompressed/u/1080p/dwMinBitRate          
	echo "1080" > streaming/uncompressed/u/1080p/wHeight              
	echo "1920" > streaming/uncompressed/u/1080p/wWidth
    else
        echo "YUV $i is invalid!"
    fi
done

#MJPEG
mkdir streaming/mjpeg/m/
for i in $MJPEG
do
    if [ $i = 360p ];then
        mkdir streaming/mjpeg/m/360p/                                            
	echo "333333" > streaming/mjpeg/m/360p/dwFrameInterval                  
	echo "333333" > streaming/mjpeg/m/360p/dwDefaultFrameInterval
	echo "10240000" > streaming/mjpeg/m/360p/dwMaxBitRate                   
	echo "460800" > streaming/mjpeg/m/360p/dwMaxVideoFrameBufferSize        
	echo "10240000" > streaming/mjpeg/m/360p/dwMinBitRate                   
	echo "360" > streaming/mjpeg/m/360p/wHeight                       
	echo "640" > streaming/mjpeg/m/360p/wWidth 
    elif [ $i = 720p ];then
        mkdir streaming/mjpeg/m/720p/                                       
	echo "333333" > streaming/mjpeg/m/720p/dwFrameInterval                   
	echo "333333" > streaming/mjpeg/m/720p/dwDefaultFrameInterval
	echo "20480000" > streaming/mjpeg/m/720p/dwMaxBitRate                    
	echo "1843200" > streaming/mjpeg/m/720p/dwMaxVideoFrameBufferSize        
	echo "20480000" > streaming/mjpeg/m/720p/dwMinBitRate                    
	echo "720" > streaming/mjpeg/m/720p/wHeight                              
	echo "1280" > streaming/mjpeg/m/720p/wWidth 
    elif [ $i = 1080p ];then
        mkdir streaming/mjpeg/m/1080p/                                    
	echo "333333" > streaming/mjpeg/m/1080p/dwFrameInterval             
	echo "333333" > streaming/mjpeg/m/1080p/dwDefaultFrameInterval
	echo "40960000" > streaming/mjpeg/m/1080p/dwMaxBitRate            
	echo "4147200" > streaming/mjpeg/m/1080p/dwMaxVideoFrameBufferSize       
	echo "40960000" > streaming/mjpeg/m/1080p/dwMinBitRate                   
	echo "1080" > streaming/mjpeg/m/1080p/wHeight                            
	echo "1920" > streaming/mjpeg/m/1080p/wWidth 
    elif [ $i = 2160p ];then
        mkdir streaming/mjpeg/m/2160p/                                     
	echo "333333" > streaming/mjpeg/m/2160p/dwFrameInterval            
	echo "333333" > streaming/mjpeg/m/2160p/dwDefaultFrameInterval
	echo "61440000" > streaming/mjpeg/m/2160p/dwMaxBitRate             
	echo "16588800" > streaming/mjpeg/m/2160p/dwMaxVideoFrameBufferSize
	echo "61440000" > streaming/mjpeg/m/2160p/dwMinBitRate          
	echo "2160" > streaming/mjpeg/m/2160p/wHeight                   
	echo "3840" > streaming/mjpeg/m/2160p/wWidth
    else
        echo "MJPEG $i is invalid!"
    fi
done

#FRAMEBASED
mkdir streaming/framebased/fb/
for i in $H264
do
    if [ $i = 360p ];then
        mkdir streaming/framebased/fb/360p/                                      
	echo "333333" > streaming/framebased/fb/360p/dwFrameInterval     
	echo "333333" > streaming/framebased/fb/360p/dwDefaultFrameInterval
	echo "8192000" > streaming/framebased/fb/360p/dwMaxBitRate               
	echo "8192000" > streaming/framebased/fb/360p/dwMinBitRate               
	echo "360" > streaming/framebased/fb/360p/wHeight                        
	echo "640" > streaming/framebased/fb/360p/wWidth
    elif [ $i = 720p ];then
        mkdir streaming/framebased/fb/720p/                                      
	echo "333333" > streaming/framebased/fb/720p/dwFrameInterval             
	echo "333333" > streaming/framebased/fb/720p/dwDefaultFrameInterval
	echo "10240000" > streaming/framebased/fb/720p/dwMaxBitRate            
	echo "10240000" > streaming/framebased/fb/720p/dwMinBitRate       
	echo "720" > streaming/framebased/fb/720p/wHeight                 
	echo "1280" > streaming/framebased/fb/720p/wWidth  
    elif [ $i = 1080p ];then
        mkdir streaming/framebased/fb/1080p/                                
	echo "333333" > streaming/framebased/fb/1080p/dwFrameInterval            
	echo "333333" > streaming/framebased/fb/1080p/dwDefaultFrameInterval
	echo "15360000" > streaming/framebased/fb/1080p/dwMaxBitRate            
	echo "15360000" > streaming/framebased/fb/1080p/dwMinBitRate            
	echo "1080" > streaming/framebased/fb/1080p/wHeight                     
	echo "1920" > streaming/framebased/fb/1080p/wWidth
    elif [ $i = 2160p ];then
        mkdir streaming/framebased/fb/2160p/                               
	echo "333333" > streaming/framebased/fb/2160p/dwFrameInterval      
	echo "333333" > streaming/framebased/fb/2160p/dwDefaultFrameInterval
	echo "30720000" > streaming/framebased/fb/2160p/dwMaxBitRate       
	echo "30720000" > streaming/framebased/fb/2160p/dwMinBitRate            
	echo "2160" > streaming/framebased/fb/2160p/wHeight                     
	echo "3840" > streaming/framebased/fb/2160p/wWidth
    else
        echo "H264 $i is invalid!"
    fi
done
mkdir streaming/header/h/                                                
ln -s streaming/uncompressed/u/ streaming/header/h/                 
ln -s streaming/mjpeg/m/ streaming/header/h/                        
ln -s streaming/framebased/fb/ streaming/header/h/                  
                                                                    
ln -s streaming/header/h/ streaming/class/fs/                     
ln -s streaming/header/h/ streaming/class/hs/                            
ln -s streaming/header/h/ streaming/class/ss/                            
                                                                         
#-Create and setup configuration
cd ../../                                                                
mkdir configs/c.1/                                                       
echo 500 > configs/c.1/MaxPower                                        
echo 0xc0 > configs/c.1/bmAttributes                                        
mkdir configs/c.1/strings/0x409/                                    
echo "Config 1" > configs/c.1/strings/0x409/configuration           
ln -s functions/uvc.usb0/ configs/c.1/                              
ls /sys/class/udc > UDC  
echo "0x01" > bDeviceProtocol
echo "0x02" > bDeviceSubClass
echo "0xEF" > bDeviceClass

运行时会出现如下错误,暂时忽略

运行成功后在/dev下会出现video0设备

4、加载SDK模块

5、把USB线连接到电脑,运行uvc_app

运行成功后在电脑端可查看到摄像头设备

6、使用plotplayer打开摄像头

打开选项,选择视频格式为1080P

打开摄像头

目标板调试信息输出如下

已标记关键词 清除标记
相关推荐
©️2020 CSDN 皮肤主题: 编程工作室 设计师:CSDN官方博客 返回首页