Windows Phone 8 lens augmented reality

I am looking to create an AR lens for Windows Phone 8. I played with lenses and camera functions, and all this is good and good. I can put icons and images on the screen and manipulate photos that were taken with the phone. But I need to do so that I can read the camera screen in real time before taking a picture.

Example: Face Lens needs to scan the screen in real time, checking the pixels, which I suppose to calculate where someone is wearing nose / eyes / etc. the nose of clowns, or glasses, or something else, on the screen of a live camera.

I can do this with an image, but I can’t find a way to access the current frame in the camera without taking a picture. Basically, I want to scan every pixel of every frame that is displayed in the camera application. I know that it is possible, other lenses do it, but where should I look for the right method to access this.

+6
source share
1 answer

It is certainly possible. The key to this is to use the PhotoCamera.GetPreviewBufferArgb32() function.

The main idea is to get the preview buffer from the PhotoCamera object. This is done as follows:

 int[] pixelData = new int[(int)(camera.PreviewResolution.Width * camera.PreviewResolution.Height)]; camera.GetPreviewBufferArgb32(pixelData); return pixelData; 

This gives you an uncompressed .bmp image. You can then access this data to identify functions or to draw additional objects in it.

After changing the data, click WriteableBitmap() to display it as follows:

 int[] previewBuffer = GetPreviewBuffer(); pixelData.CopyTo(previewWriteableBitmap.Pixels, 0); previewWriteableBitmap.Invalidate(); 

DISCLAIMER:. Most of them were taken from an example of a camera with shades of gray , especially for event processing in combination with image capture.

+5
source

Source: https://habr.com/ru/post/943702/


All Articles