如何在 HP 触摸板上使用 webOS 命令行拍照?

发布于 2024-12-05 14:45:44 字数 736 浏览 0 评论 0原文

在 webos 上,我正在运行 openssh,并且想使用命令行脚本拍照。

我怀疑这将包括一些 luna-send 命令,或者 gst-launch

但我对文档没有任何运气。

webos 没有任何预期的捕获工具,但我可以访问 /dev/video0 设备。

编辑:我注意到触摸板安装了 ffmpeg 实用程序,但它无法识别 video4linux2 格式

到目前为止,我正在使用以下代码尝试 Gopherkhan 的建议;

luna-send -n 1 palm://com.palm.mediad.MediaCapture/startImageCapture \
'{"path":"/media/internal/foo1.png","options":[{"quality" \
:100,"flash":2,'reviewDuration':0,'exifData':{}}]}'

但它只是挂在那里什么都不做,过了一会儿就这样说了;

{"serviceName":"com.palm.mediad.MediaCapture","returnValue":false,"errorCode":-1 \
  ,"errorText":"com.palm.mediad.MediaCapture is not running."} \
(process:8534): LunaService-CRITICAL **: AppId msg type: 17

on webos, I have openssh running and would like to take a picture using the command line script.

I suspect this is going to include some luna-send command, or alternatively a gst-launch

But I am not having any luck with the docs.

webos doesn't have any of the expected capture tools, but I can access the /dev/video0 device.

Edit: i noticed that the touchpad has the ffmpeg utility installed, but it doesn't recognise the video4linux2 format

So far, I am trying Gopherkhan's suggestions with the following code;

luna-send -n 1 palm://com.palm.mediad.MediaCapture/startImageCapture \
'{"path":"/media/internal/foo1.png","options":[{"quality" \
:100,"flash":2,'reviewDuration':0,'exifData':{}}]}'

but its just hanging there doing nothing, after a while is says this;

{"serviceName":"com.palm.mediad.MediaCapture","returnValue":false,"errorCode":-1 \
  ,"errorText":"com.palm.mediad.MediaCapture is not running."} \
(process:8534): LunaService-CRITICAL **: AppId msg type: 17

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

ヤ经典坏疍 2024-12-12 14:45:44

因此,使用 luna-sends 执行此操作有点棘手,并且在技术上不受支持。

您可能想要使用 MediaCapture 库,该库可以在设备上找到:

/usr/palm/frameworks/enyo/0.10/framework/lib/mediacapture

要将其包含在您的 enyo 应用程序中,请将以下内容放入您的 dependent.js 中:

"$enyo-lib/mediacapture/"

涉及三个主要步骤。

  1. 初始化组件
  2. 捕获图像
  3. 卸载设备。

下面是一个示例:

在场景中声明组件

{
            kind: "enyo.MediaCapture", name:"mediaCaptureObj", 
            onLoaded:"_setUpLoadedState", onInitialized:"_setUpInitializedState", 
            onImageCaptureStart:"_onImageCaptureStart", onImageCaptureComplete:"_onImageCaptureComplete",
         onAutoFocusComplete:"_onAutoFocusComplete", onError:"_handleError",
            onElapsedTime:"_onElapsedTime", onVuData:"_onVuDataChange", onDuration:"_onDuration"
}

调用初始化方法

this.$.mediaCaptureObj.initialize(this.$.ViewPort);

在 onInitialized 回调中

使用属性包定位设备数量可用的。通常,描述为“相机/摄像机”、“前置麦克风”和“面向用户的相机”

var keyString;
for(var i = 0; i < this.pb.deviceKeys.length; i++)
{
    if(this.pb.deviceKeys[i].description.indexOf("Camera/Camcorder") >= 0)
    {
        keyString = this.pb.deviceKeys[i].deviceUri;
        break;
    }
}

if(keyString)
{
    var formatObj = {
                imageCaptureFormat: this.pb[keyString].supportedImageFormats[0]
            };

    this.$.mediaCaptureObj.load(keyString, formatObj);
}

拍照

var obj = {"exifData":"{\"make\": \"Palm\", \"model\": \"Pre3\", \"datetime\": \"2011:05:19 10:39:18\", \"orientation\": 1, \"geotag\": {}}","quality":90,"flash":"FLASH_ON"};

this.$.mediaCaptureObj.startImageCapture("", obj);

卸载设备

this.$.mediaCaptureObj.unload();

要使用旧的 JS 框架执行此操作,请参阅:
https://developer.palm.com/content/api /reference/javascript-libraries/media-capture.html

现在,您可以使用 luna-send 执行类似的操作,但同样,我认为它在技术上不受支持。您可能在启动/保持媒体捕获服务活动等方面遇到问题。但是,如果您想尝试,您可以执行以下操作:

1。获取媒体服务器实例 --- 这将返回一个端口实例号

luna-send -a your.app.id -i palm://com.palm.mediad/service/captureV3 '{"args":["subscribe":true]}'

这将返回带有端口号的捕获服务的位置,a la:

{"returnValue":true, "location":"palm://com.palm.mediad.MediaCaptureV3_7839/"}

由于这是订阅,因此不要终止请求。只需打开一个新终端即可。

2.打开一个新终端。使用步骤 1 中返回的“位置”作为您的新服务 URI:

luna-send -a your.app.id -i palm://com.palm.mediad.MediaCaptureV3_7839/load '{"args":["video:1", {"videoCaptureFormat":{"bitrate":2000000,"samplerate":44100,"width":640,"height":480,"mimetype":"video/mp4","codecs":"h264,mp4a.40"},"imageCaptureFormat":{"bitrate":0,"samplerate":1700888,"width":640,"height":480,"mimetype":"image/jpeg","codecs":"jpeg"},"deviceUri":"video:1"}]}'

您应该看到:

{"returnValue":true}

调用是否正确完成。您可以安全地按 ctrl+c 退出此通话。

3.拍下你的照片。(你可以在最后一次调用中按 ctrl+c,然后在此处提供参数)

luna-send -a your.app.id -i palm://com.palm.mediad.MediaCaptureV3_7839/startImageCapture '{"args":["", {"exifData":"{\"orientation\": 1, \"make\": \"HP\", \"model\": \"TouchPad\", \"datetime\": \"2011:09:22 15:34:36\", \"geotag\": {}}","quality":90,"flash":"FLASH_DISABLED","orientation":"faceup"}]}'

再次,你应该看到:

{"returnValue":true}

调用是否正确完成。

您应该听到快门声,图像将显示在“照片”应用程序的照片卷中。

So to do this with luna-sends is a bit tricky, and technically not supported.

You're probably going to want to hit the MediaCapture library, which can be found on the device here:

/usr/palm/frameworks/enyo/0.10/framework/lib/mediacapture

To include it in your enyo app drop the following in your depends.js:

"$enyo-lib/mediacapture/"

There are three main steps involved.

  1. Initializing the component
  2. Capturing the image
  3. Unloading the device.

Here's a sample:

Declare the component in your scene

{
            kind: "enyo.MediaCapture", name:"mediaCaptureObj", 
            onLoaded:"_setUpLoadedState", onInitialized:"_setUpInitializedState", 
            onImageCaptureStart:"_onImageCaptureStart", onImageCaptureComplete:"_onImageCaptureComplete",
         onAutoFocusComplete:"_onAutoFocusComplete", onError:"_handleError",
            onElapsedTime:"_onElapsedTime", onVuData:"_onVuDataChange", onDuration:"_onDuration"
}

Call the initialize method:

this.$.mediaCaptureObj.initialize(this.$.ViewPort);

In your onInitialized callback

Use the property bag to locate the number of devices that are available. Typically, the descriptions are "Camera/Camcorder", "Front Microphone", and "User facing camera"

var keyString;
for(var i = 0; i < this.pb.deviceKeys.length; i++)
{
    if(this.pb.deviceKeys[i].description.indexOf("Camera/Camcorder") >= 0)
    {
        keyString = this.pb.deviceKeys[i].deviceUri;
        break;
    }
}

if(keyString)
{
    var formatObj = {
                imageCaptureFormat: this.pb[keyString].supportedImageFormats[0]
            };

    this.$.mediaCaptureObj.load(keyString, formatObj);
}

Take a photo.

var obj = {"exifData":"{\"make\": \"Palm\", \"model\": \"Pre3\", \"datetime\": \"2011:05:19 10:39:18\", \"orientation\": 1, \"geotag\": {}}","quality":90,"flash":"FLASH_ON"};

this.$.mediaCaptureObj.startImageCapture("", obj);

Unload the device:

this.$.mediaCaptureObj.unload();

To do this with the old JS frameworks, see:
https://developer.palm.com/content/api/reference/javascript-libraries/media-capture.html

Now, you can do something similar with luna-send, but again, I don't think it's technically supported. You might have trouble with starting-up/keeping-alive the media capture service, etc. BUT, if you want to try, you could do something along the lines of:

1. get the media server instance --- this returns a port instance number

luna-send -a your.app.id -i palm://com.palm.mediad/service/captureV3 '{"args":["subscribe":true]}'

This will return a location of the capture service with a port number, a la:

{"returnValue":true, "location":"palm://com.palm.mediad.MediaCaptureV3_7839/"}

Since this is a subscription, don't kill the request. Just open a new terminal.

2. Open a new terminal. Use the "location" returned in step 1 as your new service uri:

luna-send -a your.app.id -i palm://com.palm.mediad.MediaCaptureV3_7839/load '{"args":["video:1", {"videoCaptureFormat":{"bitrate":2000000,"samplerate":44100,"width":640,"height":480,"mimetype":"video/mp4","codecs":"h264,mp4a.40"},"imageCaptureFormat":{"bitrate":0,"samplerate":1700888,"width":640,"height":480,"mimetype":"image/jpeg","codecs":"jpeg"},"deviceUri":"video:1"}]}'

You should see:

{"returnValue":true}

if the call completed correctly. You can safely ctrl+c out of this call.

3. Take your picture. (you can ctrl+c out of the last call, and just supply the args here)

luna-send -a your.app.id -i palm://com.palm.mediad.MediaCaptureV3_7839/startImageCapture '{"args":["", {"exifData":"{\"orientation\": 1, \"make\": \"HP\", \"model\": \"TouchPad\", \"datetime\": \"2011:09:22 15:34:36\", \"geotag\": {}}","quality":90,"flash":"FLASH_DISABLED","orientation":"faceup"}]}'

Again, you should see:

{"returnValue":true}

if the call completed correctly.

You should hear a shutter click, and the image will show up in the Photos app, in your Photo Roll.

苦行僧 2024-12-12 14:45:44

另一种选择是使用 gst-launch 管道,这可能会受益于使用跨平台工具。到目前为止,我已经成功使用命令行启动网络摄像头;

gst-launch camsrc .src!视频/x-raw-yuv,宽度=320,高度=240,帧率=30/1
!掌上视频编码器! avimux 名称=多路复用器!文件接收器位置=test1.avi alsasrc !
palmaudioencoder

但不拍摄单个图像;

   gst-launch -v camsrc .src_still take-picture=1 flash-ctrl=2 ! fakesink dump=true

但我无法让它识别 .src_still 选项卡。当我继续进行时,我将用这种替代方法更新这个答案。

An alternative, which might some benefit of using cross platform tools, is to the use the gst-launch pipeline. So far I have managed to start the web cam using command line;

gst-launch camsrc .src ! video/x-raw-yuv,width=320,height=240,framerate=30/1
! palmvideoencoder ! avimux name=mux ! filesink location=test1.avi alsasrc !
palmaudioencoder

but not take a single image;

   gst-launch -v camsrc .src_still take-picture=1 flash-ctrl=2 ! fakesink dump=true

but I can't get it to recognise the .src_still tab. I will update this answer with this alternative method as I proceed.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文