USB video class(又称为USB video device class or UVC)就是USB device class视频产品在不需要安装任何的驱动程序下即插即用,包括摄像头、数字摄影机、模拟视频转换器、电视卡及静态视频相机。
SoC : RK3288
Platform : Android 5.1
RK平台有自己的测试方法:在计算器中输入"83991906=",进入测试工程模式,选择CameraTest可以进行相
机的<open/close test>,<Take photo test>,<Switch mode test>等。
此脚本测试流程:打开-拍照-退出,并将结果存入本地。shell如下:
#!/system/bin/sh
# 拍照测试程序,监控照片是否生成,自动判断/dev/video设备是否存在
MONITOR_DIR=/mnt/sdcard/DCIM/Camera # 照片存放目录
ACTIVITY_DIR=/mnt/sdcard/CameraActivity.txt # 启动相机的log
PHOTO_NUMBER=/mnt/sdcard/photonumber.txt # 拍照次数的log
DEVICE_ERR=/mnt/sdcard/CameraError.txt # 没有识别到设备/dev/video0的log
open_success=0
open_failed=0
open_error=0
device_err=0;
takephoto_success=0
takephoto_failed=0
PICTURE_PIRV=0
PICTURE_NEXT=0
if [ -f "CameraTestOK.txt" ];then
rm /mnt/sdcard/*.txt
rm /mnt/sdcard/DCIM/Camera/*.jpg
fi
#
# 当没有产生/dev/video0或/dev/video1时,打开相机系统会弹窗提示"相机发生错误:无法连接到相机"
# 这里只记录错误的次数,当没有产生设备文件时,注意备份相关log
#
takephoto_function()
{
PICTURE_PIRV=`ls -l $MONITOR_DIR/*.jpg |grep "^-"| busybox wc -l`
am start -n com.android.camera2/com.android.camera.CameraActivity
if ps | grep com.android.camera2 ;then
let "open_success++"
echo "start Camera activity success number:$open_success"
echo "[$(date +%T)] start Camera activity success number:$open_success" >> $ACTIVITY_DIR
sleep 3
input tap 1910 500
PICTURE_NEXT=`ls -l $MONITOR_DIR/*.jpg |grep "^-"| busybox wc -l`
if [ $PICTURE_NEXT -gt $PICTURE_PIRV ];then
let "takephoto_success++"
echo "Take photo success:$takephoto_success"
echo "[$(date +%T)] Take photo success:$takephoto_success" >> $PHOTO_NUMBER
else
let "takephoto_failed++"
echo "[$(date +%T)] Take photo failed:$takephoto_failed" >> $PHOTO_NUMBER
fi
# am force-stop com.android.camera2
PROID=`ps |grep com.android.camera2 |grep -v "grep"|busybox awk '{print $2}'`
kill -9 $PROID
else
let "open_failed++"
echo "[$(date +%T)] start Camera activity failed number:$open_failed" >> $ACTIVITY_DIR
fi
}
while(($open_success<=1000))
do
if ls -l /dev/video0 ;then
takephoto_function;
elif ls -l /dev/video1 ;then
let "device_err++"
echo "[$(date +%T)] Camera device is /dev/video1" >> $DEVICE_ERR
echo "[$(date +%T)] ---------- Camera device has change!!!!!!!!!!!!!!!!!!!"
takephoto_function;
conitue
else
let "open_error++"
echo "------</dev/video0> and </dev/video1> not exist.-------"
echo "[$(date +%T)] Camera device </dev/video0> and </dev/video1> not exist:$open_error" >> $DEVICE_ERR
sleep 2
conitue
fi
# PROID=`ps -fe | grep com.android.camera2 | awk '{print $2}' | head -n 1`
# kill -9 $PROID
# am force-stop com.android.camera2
done
PICTURE=`ls -l $MONITOR_DIR/*.jpg |grep "^-"| busybox wc -l`
echo "----------------------------------------------------"
echo "1.total Camera picture number:$PICTURE"
echo "2.start Camera app success number:$open_success"
echo "3.Take photo success number:$takephoto_success"
echo "4.can not find device [/dev/video0] number:$open_error"
echo "5.find Camera device [/dev/video1] number:$device_err"
echo "----------------------------------------------------"
NOTE:
1. 需要确定系统的Camera应用包名与全路径名称,作相应的修改
2.通过adb push 到/system/bin/下,运行前su下即可。
shell作用:监控Camera2应用是否运行,并判断是否存在videoX设备,通过对比生成照片的数量判断是否拍照成功。