How to capture a Picture

+1 vote
asked Jun 15, 2018 by diaz1111 (320 points)
I am currently using `HelloARMultiTarget_SameImage` Sample . I need to put a capture button and capture an image . But i can not find any method in `HelloAR.java` and `CameraDevice.java` . How can i will be able to to take picture during Scanning ? Is it possible with EasyAR's `CameraDevice` or i have to use create my own  camera ?

Please let me know stuck here for 2 days .

Thanks.

2 Answers

0 votes
answered Jun 15, 2018 by albert52 (31,850 points)
selected Jun 15, 2018 by diaz1111
 
Best answer
First of all, the easyar SDK does not have the ability to integrate screenshots, which is not the core feature of the easyar SDK. It is recommended that you use third-party plugins
0 votes
answered Jul 7, 2018 by derzuomaia (1,190 points)

Yes, it is possible to capture frames from the video using the EasyAR CameraDevice.

At the EasyAR Android Samples, on the file HelloAR, method initialize(), a CameraFrameStreamer is created from the CameraDevice. You will use the CameraFrameStreamer to capture the frames. 

I recommend you do the frame capture at the render() method, do like that:

Frame frame = streamer.peek();
if (frame.images().size()>0) {
    int size = frame.images().get(0).buffer().size();
    byte[] raw_frame = new byte[size];
    frame.images().get(0).buffer().copyTo(raw_frame, 0);
}

This raw_frame pixels are on the NV21 format. You can convert it to Y or RGB, look at this explanation:

https://stackoverflow.com/questions/5272388/extract-black-and-white-image-from-android-cameras-nv21-format/12702836#12702836

commented Jul 16, 2018 by brewman (120 points)
and in unity?
commented Jul 16, 2018 by derzuomaia (1,190 points)
In Unity, I don't know how to do, but should be possible.
Welcome to EasyAR SDK Q&A, where you can ask questions and receive answers from other members of the community.
...