How to take a picture using command line on webOS on HP touchpad?

女生的网名这么多〃 提交于 2019-12-04 11:58:01

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.

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.

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!