After many long days and nights of searching, struggling and always coming up empty handed, I have finally figured out how to take pictures using enyo on a WebOS platform. It has been so frustrating because all the resources I have found are slightly vague and not very useful. Documentation for the framework is slightly lacking from what I've seen and it's been a real fight to find a solution. But as I said before I have finally found one. I'm planning on implementing it in with the rest of my UI design for my QR Reader and hopefully it will all work out smoothly... (that never happens...).
But for those you just as frustrated as I was, here's my .js file for my project so far.
enyo.kind
({
name: "MyApps.Capture",
kind: "VFlexBox",
components:
[
{kind: "Video", name: "streamTheVideo", style:"width:98%;height:93%;top:6%;left:1%;position:fixed"},
{kind: "enyo.MediaCapture", name: "mediaCaptureCamera", onInitialized: "loadCamera",
onImageCaptureComplete: "pictureTaken", onError: "someErrorOccured"},
{kind:"Button", name: "myButton", caption: "Take Picture", onclick:"capturePicture"}
],
load: function()
{
this.$.mediaCaptureCamera.initialize(this.$.streamTheVideo);
},
rendered: function()
{
this.inherited(arguments);
this.$.mediaCaptureCamera.initialize(this.$.streamTheVideo);
},
unload: function()
{
this.$.mediaCaptureCamera.unload();
},
loadCamera: function(inSender, inResponse)
{
var format;
for (i = 0; inResponse["video:1"].supportedImageFormats.length != i; ++i) {
fmt = inResponse["video:1"].supportedImageFormats[i];
if (fmt.mimetype == "image/jpeg") {
break;
}
}
this.$.mediaCaptureCamera.load(inResponse["video:1"].deviceUri, fmt);
},
pictureTaken: function(inSender)
{
this.captureType = "IMAGE";
this.$.myButton.caption = "picture Taken";
},
capturePicture: function()
{
var myexifdata = {
orientation: 3
};
var ImageCaptureOptions ={orientation: 3,'quality' : 100,'flash':"FLASH_AUTO",'reviewDuration':5,'exifData':myexifdata};
this.picName = "PicSample" + Date.parse(new Date()) ;
this.$.mediaCaptureCamera.startImageCapture('/media/internal/dts/image/' + this.picName + '.jpg', ImageCaptureOptions);
}
});
Some of the stuff I'm probably and hopefully end up changing when I implement it in my QR Reader, but for now it just works.
//END OF LINE
No comments:
Post a Comment