简体   繁体   English

android(linux)控制uvc相机实现ptz

[英]android (linux) control uvc camera to implement ptz

I want to control a ptz camera from android,actually i do that in jni and use linux api,the camera is connected to android-tvbox's usb interface directly, ,below is the code: 我想从android控制一个ptz摄像头,实际上我在jni中做到这一点并使用linux api,该摄像头直接连接到android-tvbox的usb界面,下面是代码:

    struct v4l2_ext_control xctrls[1];
    struct v4l2_ext_controls ctrls;

    memset(xctrls, 0, sizeof xctrls);
    memset(&ctrls, 0, sizeof ctrls);
    xctrls[0].id = V4L2_CID_PAN_ABSOLUTE;
    xctrls[0].value = 20;
    ctrls.ctrl_class = V4L2_CTRL_CLASS_CAMERA;
    ctrls.count = 1;
    ctrls.controls = xctrls;
    //xioctl(fd, VIDIOC_S_EXT_CTRLS, &ctrls);
    int result = ioctl(fd, VIDIOC_S_CTRL, &ctrls);
    //LOGE("Cannot identify:%d , %d, %s", result, errno, strerror (errno));
    LOGE("Cannot open '%d': %d, %s", result, errno, strerror (errno));

and it return invalid argument , can anyone tell me which argument is wrong?Or my code is incorrect... 它返回无效的参数,谁能告诉我哪个参数是错误的?或者我的代码不正确...

I have solved this problem. 我已经解决了这个问题。 Actually, you need to design your Android source code in UVC (USB Video Class) module, and UVC is located in the kernel of the whole android source code. 实际上,您需要在UVC(USB视频类)模块中设计Android源代码,而UVC位于整个android源代码的内核中。

What's more, you have to cooperate with the camera's vendor, because they have deep insights into the firmware of PTZ cameras, and Android's UVC version should apply to camera firmware, data length and control type (absolute or relative). 而且,您必须与相机的供应商合作,因为他们对PTZ相机的固件有深入的了解,而Android的UVC版本应适用于相机的固件,数据长度和控件类型(绝对或相对)。

Furthermore, Android kernel's version is generally 3.10. 此外,Android内核的版本通常为3.10。 When you control camera with absolute control, it may move in one direction but not another one, because the Android UVC control parameters of absolute is unsigned: you should change it to signed parameters. 当您使用绝对控制来控制摄像机时,它可能会朝一个方向移动,而不能朝另一个方向移动,因为Android UVC绝对控制参数是无符号的:您应该将其更改为有符号的参数。

When you control in relative, it's a little more complicated, for you should add relative control in Android source code because Android kernel in 3.10 does not support it. 当您以相对方式进行控制时,会稍微复杂一点,因为您应该在Android源代码中添加相对控制,因为3.10中的Android内核不支持它。 You can get the Linux kernel patch to add relative movements. 您可以获取Linux内核补丁以添加相对运动。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM