I'm using WinJs to create an app with javascript that get camera preview. With preview I get a videoframe but now I would like to get all pixel rgba data for calculate average color and other infos. I use getPreviewFrameAsync method of Media.Capture class. Is it right?
mediaCapture.getPreviewFrameAsync(videoFrame)
.then(function (currentFrame) {
//get pixeldata rgba of frame of camerapreview
}
Documentation in javascript of these classes is very poor.... Thanks.
IngD
I use getPreviewFrameAsync method of Media.Capture class. Is it right?
Yes, with this you can get a videoframe object. After then, you can get the SoftwareBitmap object which contains the pixel data by VideoFrame.SoftwareBitmap property. Code like follows:
return oMediaCapture.getPreviewFrameAsync(videoFrame)
.then(function (currentFrame) {
// Collect the resulting frame
var frameBitmap = currentFrame.softwareBitmap;
// Show the frame information
frameInfoTextBlock.textContent = frameBitmap.pixelWidth + "x" + frameBitmap.pixelHeight + " " +
stringOfEnumeration(Windows.Graphics.DirectX.DirectXPixelFormat, frameBitmap.bitmapPixelFormat);
The official sample CameraGetPreviewFrame provides the example written on javascript language, and it has examples about the features that you want you can reference.