webostouchpad

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


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

Solution

  • 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.