RK3588平台用v4l工具调试USB摄像头实践(亮度,饱和度,对比度,色相等)

目录

前言:v4l-utils简介

一:查找当前的摄像头设备

二:查看当前摄像头支持的v4l2-ctl调试参数

三根据提示设置对应参数,在提示范围内设置

四:常用调试命令

五:应用内执行命令方法


前言: v4l-utils 简介

v4l-utils工具是由Linuxtv维护的一个V4L2开发套件,它提供一系列V4L2及media framework相关的工具,用来配置V4L2子设备的属性,测试V4L2设备,并提供如libv4l2.so开发库等等。

本章主要介绍v4l-utils中的两个命令行工具:media-ctl和v4l2-ctl。

  • media-ctl:用以查看、配置拓扑结构;
  • v4l2-ctl:用以配置v4l2 controls,可抓帧,设置vin、isp、sensor参数。

在 Rockchip 发布的 Linux SDK 中,默认已集成了 v4l-utils 包。

一:查找当前的摄像头设备

grep '' /sys/class/video4linux/video*/name

红框代表是外接的USB摄像头

二:查看当前摄像头支持的v4l2-ctl调试参数

v4l2-ctl -d /dev/video21 --list-ctrls

三根据提示设置对应参数,在提示范围内设置

亮度

v4l2-ctl -d /dev/video21 --set-ctrl 'brightness=64'

效果如下:

四:常用调试命令

亮度

v4l2-ctl -d /dev/video21 --set-ctrl 'brightness=64'

饱和度

v4l2-ctl -d /dev/video21 --set-ctrl 'saturation=100'

对比度

v4l2-ctl -d /dev/video21 --set-ctrl 'contrast=95'

锐度

v4l2-ctl -d /dev/video21 --set-ctrl 'sharpness=7'

五:应用内执行命令方法

Path = "/dev/video21"

public static boolean upgradeRootPermission(String path) {

Process process = null;

DataOutputStream os = null;

try {

String cmd = "chmod 777 " + path;

process = Runtime.getRuntime().exec("su"); //切换到root帐号

os = new DataOutputStream(process.getOutputStream());

os.writeBytes(cmd + "\n");

os.writeBytes("exit\n");

os.flush();

process.waitFor();

} catch (Exception e) {

} finally {

try {

if (os != null) {

os.close();

}

process.destroy();

} catch (Exception e) {

}

}

try {

if (process == null) {

return false;

}

return process.waitFor() == 0;

} catch (InterruptedException e) {

e.printStackTrace();

}

return false;

}

Cmd示例:v4l2-ctl -d /dev/video21 --set-ctrl 'brightness=64'

public static boolean exeCmdForSu(String command) {

Log.d("exeCmdForSu", "command = " + command);

boolean result = false;

DataOutputStream dataOutputStream = null;

BufferedReader errorStream = null;

try {

Process process = Runtime.getRuntime().exec("su");

dataOutputStream = new DataOutputStream(process.getOutputStream());

String s = command + "\n";

dataOutputStream.write(s.getBytes(Charset.forName("utf-8")));

dataOutputStream.flush();

dataOutputStream.writeBytes("exit\n");

dataOutputStream.flush();

process.waitFor();

errorStream = new BufferedReader(new InputStreamReader(process.getErrorStream()));

String msg;

String line;

for (msg = ""; (line = errorStream.readLine()) != null; msg = msg + line) {

}

Log.d("exeCmdForSu", "exeCmdForSu msg is " + msg);

if (!msg.contains("Failure")) {

result = true;

}

} catch (Exception var16) {

Exception e = var16;

Log.e("exeCmdForSu", e.getMessage(), e);

} finally {

try {

if (dataOutputStream != null) {

dataOutputStream.close();

}

if (errorStream != null) {

errorStream.close();

}

} catch (IOException var15) {

IOException e = var15;

Log.e("exeCmdForSu", e.getMessage(), e);

}

}

return result;

}

相关推荐
fatiaozhang95271 小时前
中兴云电脑W102D_晶晨S905X2_2+16G_mt7661无线_安卓9.0_线刷固件包
android·adb·电视盒子·魔百盒刷机·魔百盒固件
CYRUS_STUDIO2 小时前
Android APP 热修复原理
android·app·hotfix
鸿蒙布道师3 小时前
鸿蒙NEXT开发通知工具类(ArkTs)
android·ios·华为·harmonyos·arkts·鸿蒙系统·huawei
鸿蒙布道师3 小时前
鸿蒙NEXT开发网络相关工具类(ArkTs)
android·ios·华为·harmonyos·arkts·鸿蒙系统·huawei
菜鸟射手3 小时前
QT creater和vs2017文件路径问题
linux·c++·windows·qt
大耳猫3 小时前
【解决】Android Gradle Sync 报错 Could not read workspace metadata
android·gradle·android studio
爱编程的鱼3 小时前
Windows 各版本查找计算机 IP 地址指南
人工智能·windows·网络协议·tcp/ip·tensorflow
sukalot3 小时前
Windows 图形显示驱动开发-WDDM 1.2功能—Windows 8 中的 DirectX 功能改进(九)
windows
ta叫我小白3 小时前
实现 Android 图片信息获取和 EXIF 坐标解析
android·exif·经纬度
simple_whu3 小时前
解决编译pcl时报错‘chrono_literals‘: is not a member of ‘std‘
c++·windows·visual studio