I am new to google-project-tango, and I want to record the images from Tango's color camera image buffer rather than fisheye camera. I saw henderso's sharing -- reading of the GL buffer to save the image, and modified his code to record the images-- keep saving every image when we get any onFrameAvailable() callback. I also try to lock the buffer or use semaphore, when i got the onframeavailable callback. But the results look like this one--is it the synchronization problem of GL buffer?.
The MainActivity implements TangoCameraScreengrabCallback:
public void onFrameAvailable(int arg0) {
if (mIsRecording){
tangoCameraPreview.takeSnapShot();
try {
mutex_on_mIsRecording.acquire();
} catch (InterruptedException e) {
e.printStackTrace();
}
tangoCameraPreview.onFrameAvailable();
mutex_on_mIsRecording.release();
}
}
And tangoCameraPreview.onFrameAvailable() will do as follows:
public void onFrameAvailable() {
super.onFrameAvailable();
if(recording) {
synchronized (intBuffer){
screenGrabRenderer.grabNextScreen(SCREEN_GRAB_X, SCREEN_GRAB_Y, SCREEN_GRAB_W, SCREEN_GRAB_H, intBuffer);
}
}
}