Skip to content

Commit 2701df5

Browse files
committed
2 parents e0c391a + f789ba6 commit 2701df5

File tree

1 file changed

+19
-6
lines changed

1 file changed

+19
-6
lines changed

README.md

Lines changed: 19 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,23 @@
11
# Processing Video implementation for Android
2-
In this branch, I'm maintaining another approach to render camera preview on processing's `GLSurfaceView`.
3-
The idea is to render camera preview on a `SurfaceTexture` and as soon as the new frame is received, copy the data from this `SurfaceTexture` to a custom texure bound to target `GL_TEXTURE_2D`.
4-
We cannot directly render to processing's own texture because it's bound `GL_TEXTURE_2D` target, whereas for the preview to happen, the texture should be bound to `GL_TEXTURE_EXTERNAL_OES`.
2+
This library tries to expose the same API endpoints as that of processing-video library for PC. The sketch from processing-video library works for Android.
53

6-
**Behind the hood :**
4+
**A primitive example :**
5+
```
6+
import in.omerjerk.processing.video.android.*;
7+
8+
Capture cap;
79
8-
I create a framebuffer object and a custom texture object, which is bound to target `GL_TEXTURE_2D`, and attach this texture to the previously created framebuffer at `GL_COLOR_ATTACHMENT0`. I then render SurfaceTexture's shader output to this framebuffer and it atomatically gets rendered upon the custom texture I created. I then call `glReadPixels` and assign these read pixels to `PImage`'s pixel array.
10+
void setup() {
11+
size(720, 1280, P2D);
12+
cap = new Capture(this);
13+
String[] list = cap.list();
14+
Capture.printCompatibleResolutionsList(cap);
15+
}
916
10-
For an alternative approach, please head over to testing branch.
17+
void draw() {
18+
image(cap, 0, 0);
19+
}
20+
```
21+
22+
**Behind the hood :**
23+
The idea is to render camera preview on a `SurfaceTexture` and as soon as the new frame is received, copy the data from this `SurfaceTexture` to a custom texure bound to target `GL_TEXTURE_2D` (Note : We cannot directly render to a texture bound to `GL_TEXTURE_2D` target, because for the preview to happen, the texture must be bound to `GL_TEXTURE_EXTERNAL_OES`). This custom texture is then rendered to a PGraphics object. The backing texture of that PGraphics object is then used as the texture cache for our PImage file which stores the video.

0 commit comments

Comments
 (0)