Transpiled version (5714L) is out of date.
1 | !7 |
2 | |
3 | import android.app.Activity; |
4 | import android.widget.*; |
5 | import android.graphics.*; |
6 | import android.hardware.Camera; |
7 | import android.view.*; |
8 | |
9 | p { |
10 | print("Listing cameras..."); |
11 | |
12 | runOnUiThread(r { |
13 | int n = Camera.getNumberOfCameras(); |
14 | System.out.println("Cameras: " + n); |
15 | |
16 | final Camera cam = Camera.open(0/*n-1*/); |
17 | |
18 | Camera.Parameters p = cam.getParameters(); |
19 | p.setPreviewSize(100, 100); |
20 | cam.setParameters(p); |
21 | |
22 | SurfaceView surfaceView = new SurfaceView(androidContext()); |
23 | SurfaceHolder surfaceHolder = surfaceView.getHolder(); |
24 | surfaceHolder.addCallback(new CamCallback()); |
25 | surfaceHolder.setType(SurfaceHolder.SURFACE_TYPE_PUSH_BUFFERS); |
26 | |
27 | androidShow(surfaceView); |
28 | |
29 | cam.setPreviewDisplay(surfaceHolder); |
30 | cam.startPreview(); |
31 | |
32 | print("Preview started."); |
33 | |
34 | surfaceView.post(r { |
35 | cam.takePicture(null, null, null, new JpegCallback()); |
36 | }); |
37 | |
38 | print("Waiting for callback"); |
39 | }); |
40 | } |
41 | |
42 | static class CamCallback implements SurfaceHolder.Callback { |
43 | public void surfaceChanged (SurfaceHolder holder, int format, int width, int height) { |
44 | print("surfaceChanged"); |
45 | } |
46 | public void surfaceCreated (SurfaceHolder holder) { |
47 | print("surfaceCreated"); |
48 | } |
49 | public void surfaceDestroyed (SurfaceHolder holder) { |
50 | print("surfaceDestroyed"); |
51 | } |
52 | } |
53 | |
54 | static class ShutterCallback implements Camera.ShutterCallback { |
55 | public void onShutter() { |
56 | print("Shutter!"); |
57 | } |
58 | } |
59 | |
60 | static class JpegCallback implements Camera.PictureCallback { |
61 | public void onPictureTaken (final byte[] data, final Camera cam) { |
62 | cam.release(); |
63 | androidShowPrintLog(); |
64 | thread { |
65 | print("Camera released."); |
66 | print("Picture data: " + data.length); |
67 | print("Uploading..."); |
68 | print(uploadToImageServer_rawBytes(data, "Phone image")); |
69 | } |
70 | } |
71 | } |
Began life as a copy of #1000429
download show line numbers debug dex old transpilations
Travelled to 18 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, exkalrxbqyxc, gwrvuhgaqvyk, hxnwyiuffukg, ishqpsrjomds, lpdgvwnxivlt, mqqgnosmbjvj, mrjhfnjfopze, nbgitpuheiab, onxytkatvevr, pyentgdyhuwx, pzhvpgtvlbxg, tslmcundralx, tvejysmllsmz, vouqrxazstgt
No comments. add comment
Snippet ID: | #1000431 |
Snippet name: | Android: Take picture & upload (dev.) |
Eternal ID of this version: | #1000431/11 |
Text MD5: | ffb65327b3b9e8be023e862da939fe08 |
Author: | stefan |
Category: | javax android |
Type: | JavaX source code (Android) |
Public (visible to everyone): | Yes |
Archived (hidden from active list): | No |
Created/modified: | 2018-05-07 18:11:23 |
Source code size: | 1900 bytes / 71 lines |
Pitched / IR pitched: | No / No |
Views / Downloads: | 760 / 763 |
Version history: | 10 change(s) |
Referenced in: | [show references] |