{"action":"created","comment":{"url":"https://api.github.com/repos/halide/Halide/pulls/comments/29730426","id":29730426,"diff_hunk":"@@ -0,0 +1,568 @@\n+/*\n+ * Copyright 2014 The Android Open Source Project\n+ *\n+ * Licensed under the Apache License, Version 2.0 (the \"License\");\n+ * you may not use this file except in compliance with the License.\n+ * You may obtain a copy of the License at\n+ *\n+ *       http://www.apache.org/licenses/LICENSE-2.0\n+ *\n+ * Unless required by applicable law or agreed to in writing, software\n+ * distributed under the License is distributed on an \"AS IS\" BASIS,\n+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n+ * See the License for the specific language governing permissions and\n+ * limitations under the License.\n+ */\n+\n+package com.example.helloandroidcamera2;\n+\n+import android.app.Activity;\n+import android.app.AlertDialog;\n+import android.app.Dialog;\n+import android.app.DialogFragment;\n+import android.app.Fragment;\n+import android.content.Context;\n+import android.content.DialogInterface;\n+import android.graphics.ImageFormat;\n+import android.hardware.camera2.CameraAccessException;\n+import android.hardware.camera2.CameraCaptureSession;\n+import android.hardware.camera2.CameraCharacteristics;\n+import android.hardware.camera2.CameraDevice;\n+import android.hardware.camera2.CameraManager;\n+import android.hardware.camera2.CaptureRequest;\n+import android.hardware.camera2.CaptureResult;\n+import android.hardware.camera2.TotalCaptureResult;\n+import android.hardware.camera2.params.StreamConfigurationMap;\n+import android.media.Image;\n+import android.media.ImageReader;\n+import android.os.Bundle;\n+import android.os.Handler;\n+import android.os.HandlerThread;\n+import android.os.Message;\n+import android.util.Log;\n+import android.util.Size;\n+import android.view.LayoutInflater;\n+import android.view.Surface;\n+import android.view.SurfaceHolder;\n+import android.view.SurfaceView;\n+import android.view.View;\n+import android.view.ViewGroup;\n+import android.widget.Toast;\n+\n+import com.android.ex.camera2.blocking.BlockingCameraManager;\n+import com.android.ex.camera2.blocking.BlockingCameraManager.BlockingOpenException;\n+import com.android.ex.camera2.blocking.BlockingSessionCallback;\n+import com.android.ex.camera2.blocking.BlockingStateCallback;\n+import com.android.ex.camera2.exceptions.TimeoutRuntimeException;\n+\n+import java.util.ArrayList;\n+import java.util.Arrays;\n+import java.util.Collections;\n+import java.util.Comparator;\n+import java.util.List;\n+import java.util.concurrent.Semaphore;\n+\n+public class Camera2BasicFragment extends Fragment implements View.OnClickListener {\n+\n+    /**\n+     * Tag for the {@link Log}.\n+     */\n+    private static final String TAG = \"Camera2BasicFragment\";\n+\n+    private static final int STATE_TIMEOUT_MS = 5000;\n+    private static final int SESSION_WAIT_TIMEOUT_MS = 2500;\n+\n+    private static final Size IMAGE_READER_SIZE = new Size(1920, 1440);\n+    private static final int IMAGE_READER_BUFFER_SIZE = 16;\n+\n+    private final SurfaceHolder.Callback mSurfaceCallback\n+            = new SurfaceHolder.Callback() {\n+\n+        @Override\n+        public void surfaceCreated(SurfaceHolder holder) {\n+            // The surface is ready. Make its buffers use the YV12 format and use the NDK to\n+            // reconfigure its buffers to be of a different size than on screen (i.e., use the\n+            // resolution of the ImageReader instead and use the hardware scaler to interpolate).\n+            // (If you don't set it here, funny things happen when if you sleep the device).\n+            holder.setFormat(ImageFormat.YV12);\n+            JNIUtils.configureSurface(holder.getSurface(),\n+                    mImageReader.getWidth(), mImageReader.getHeight());\n+            mSurface = holder.getSurface();\n+            openCamera();\n+        }\n+\n+        @Override\n+        public void surfaceChanged(SurfaceHolder holder, int format, int width,\n+                int height) {\n+","path":"apps/HelloAndroidCamera2/src/com/example/helloandroidcamera2/Camera2BasicFragment.java","position":97,"original_position":97,"commit_id":"06447b132956933ef28b897701299b002a23dfe2","original_commit_id":"06447b132956933ef28b897701299b002a23dfe2","user":{"login":"steven-johnson","id":328955,"avatar_url":"https://avatars.githubusercontent.com/u/328955?v=3","gravatar_id":"","url":"https://api.github.com/users/steven-johnson","html_url":"https://github.com/steven-johnson","followers_url":"https://api.github.com/users/steven-johnson/followers","following_url":"https://api.github.com/users/steven-johnson/following{/other_user}","gists_url":"https://api.github.com/users/steven-johnson/gists{/gist_id}","starred_url":"https://api.github.com/users/steven-johnson/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/steven-johnson/subscriptions","organizations_url":"https://api.github.com/users/steven-johnson/orgs","repos_url":"https://api.github.com/users/steven-johnson/repos","events_url":"https://api.github.com/users/steven-johnson/events{/privacy}","received_events_url":"https://api.github.com/users/steven-johnson/received_events","type":"User","site_admin":false},"body":"If these are deliberately empty, it's probably good form to add a one-line comment to that effect","created_at":"2015-05-06T02:15:20Z","updated_at":"2015-05-06T02:15:20Z","html_url":"https://github.com/halide/Halide/pull/778#discussion_r29730426","pull_request_url":"https://api.github.com/repos/halide/Halide/pulls/778","_links":{"self":{"href":"https://api.github.com/repos/halide/Halide/pulls/comments/29730426"},"html":{"href":"https://github.com/halide/Halide/pull/778#discussion_r29730426"},"pull_request":{"href":"https://api.github.com/repos/halide/Halide/pulls/778"}}},"pull_request":{"url":"https://api.github.com/repos/halide/Halide/pulls/778","id":34782728,"html_url":"https://github.com/halide/Halide/pull/778","diff_url":"https://github.com/halide/Halide/pull/778.diff","patch_url":"https://github.com/halide/Halide/pull/778.patch","issue_url":"https://api.github.com/repos/halide/Halide/issues/778","number":778,"state":"open","locked":false,"title":"Add Android camera2 + Halide edge detector example.","user":{"login":"jiawen","id":85107,"avatar_url":"https://avatars.githubusercontent.com/u/85107?v=3","gravatar_id":"","url":"https://api.github.com/users/jiawen","html_url":"https://github.com/jiawen","followers_url":"https://api.github.com/users/jiawen/followers","following_url":"https://api.github.com/users/jiawen/following{/other_user}","gists_url":"https://api.github.com/users/jiawen/gists{/gist_id}","starred_url":"https://api.github.com/users/jiawen/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jiawen/subscriptions","organizations_url":"https://api.github.com/users/jiawen/orgs","repos_url":"https://api.github.com/users/jiawen/repos","events_url":"https://api.github.com/users/jiawen/events{/privacy}","received_events_url":"https://api.github.com/users/jiawen/received_events","type":"User","site_admin":false},"body":"Also added minor fixes to the HelloAndroid build scripts.","created_at":"2015-05-06T01:21:25Z","updated_at":"2015-05-06T02:15:20Z","closed_at":null,"merged_at":null,"merge_commit_sha":null,"assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/halide/Halide/pulls/778/commits","review_comments_url":"https://api.github.com/repos/halide/Halide/pulls/778/comments","review_comment_url":"https://api.github.com/repos/halide/Halide/pulls/comments{/number}","comments_url":"https://api.github.com/repos/halide/Halide/issues/778/comments","statuses_url":"https://api.github.com/repos/halide/Halide/statuses/06447b132956933ef28b897701299b002a23dfe2","head":{"label":"jiawen:camera2tutorial","ref":"camera2tutorial","sha":"06447b132956933ef28b897701299b002a23dfe2","user":{"login":"jiawen","id":85107,"avatar_url":"https://avatars.githubusercontent.com/u/85107?v=3","gravatar_id":"","url":"https://api.github.com/users/jiawen","html_url":"https://github.com/jiawen","followers_url":"https://api.github.com/users/jiawen/followers","following_url":"https://api.github.com/users/jiawen/following{/other_user}","gists_url":"https://api.github.com/users/jiawen/gists{/gist_id}","starred_url":"https://api.github.com/users/jiawen/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jiawen/subscriptions","organizations_url":"https://api.github.com/users/jiawen/orgs","repos_url":"https://api.github.com/users/jiawen/repos","events_url":"https://api.github.com/users/jiawen/events{/privacy}","received_events_url":"https://api.github.com/users/jiawen/received_events","type":"User","site_admin":false},"repo":{"id":13105445,"name":"Halide","full_name":"jiawen/Halide","owner":{"login":"jiawen","id":85107,"avatar_url":"https://avatars.githubusercontent.com/u/85107?v=3","gravatar_id":"","url":"https://api.github.com/users/jiawen","html_url":"https://github.com/jiawen","followers_url":"https://api.github.com/users/jiawen/followers","following_url":"https://api.github.com/users/jiawen/following{/other_user}","gists_url":"https://api.github.com/users/jiawen/gists{/gist_id}","starred_url":"https://api.github.com/users/jiawen/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jiawen/subscriptions","organizations_url":"https://api.github.com/users/jiawen/orgs","repos_url":"https://api.github.com/users/jiawen/repos","events_url":"https://api.github.com/users/jiawen/events{/privacy}","received_events_url":"https://api.github.com/users/jiawen/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/jiawen/Halide","description":"a language for image processing and computational photography","fork":true,"url":"https://api.github.com/repos/jiawen/Halide","forks_url":"https://api.github.com/repos/jiawen/Halide/forks","keys_url":"https://api.github.com/repos/jiawen/Halide/keys{/key_id}","collaborators_url":"https://api.github.com/repos/jiawen/Halide/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/jiawen/Halide/teams","hooks_url":"https://api.github.com/repos/jiawen/Halide/hooks","issue_events_url":"https://api.github.com/repos/jiawen/Halide/issues/events{/number}","events_url":"https://api.github.com/repos/jiawen/Halide/events","assignees_url":"https://api.github.com/repos/jiawen/Halide/assignees{/user}","branches_url":"https://api.github.com/repos/jiawen/Halide/branches{/branch}","tags_url":"https://api.github.com/repos/jiawen/Halide/tags","blobs_url":"https://api.github.com/repos/jiawen/Halide/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/jiawen/Halide/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/jiawen/Halide/git/refs{/sha}","trees_url":"https://api.github.com/repos/jiawen/Halide/git/trees{/sha}","statuses_url":"https://api.github.com/repos/jiawen/Halide/statuses/{sha}","languages_url":"https://api.github.com/repos/jiawen/Halide/languages","stargazers_url":"https://api.github.com/repos/jiawen/Halide/stargazers","contributors_url":"https://api.github.com/repos/jiawen/Halide/contributors","subscribers_url":"https://api.github.com/repos/jiawen/Halide/subscribers","subscription_url":"https://api.github.com/repos/jiawen/Halide/subscription","commits_url":"https://api.github.com/repos/jiawen/Halide/commits{/sha}","git_commits_url":"https://api.github.com/repos/jiawen/Halide/git/commits{/sha}","comments_url":"https://api.github.com/repos/jiawen/Halide/comments{/number}","issue_comment_url":"https://api.github.com/repos/jiawen/Halide/issues/comments{/number}","contents_url":"https://api.github.com/repos/jiawen/Halide/contents/{+path}","compare_url":"https://api.github.com/repos/jiawen/Halide/compare/{base}...{head}","merges_url":"https://api.github.com/repos/jiawen/Halide/merges","archive_url":"https://api.github.com/repos/jiawen/Halide/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/jiawen/Halide/downloads","issues_url":"https://api.github.com/repos/jiawen/Halide/issues{/number}","pulls_url":"https://api.github.com/repos/jiawen/Halide/pulls{/number}","milestones_url":"https://api.github.com/repos/jiawen/Halide/milestones{/number}","notifications_url":"https://api.github.com/repos/jiawen/Halide/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/jiawen/Halide/labels{/name}","releases_url":"https://api.github.com/repos/jiawen/Halide/releases{/id}","created_at":"2013-09-25T21:07:29Z","updated_at":"2013-09-25T21:07:32Z","pushed_at":"2015-05-06T01:17:42Z","git_url":"git://github.com/jiawen/Halide.git","ssh_url":"git@github.com:jiawen/Halide.git","clone_url":"https://github.com/jiawen/Halide.git","svn_url":"https://github.com/jiawen/Halide","homepage":"http://halide-lang.org","size":81932,"stargazers_count":0,"watchers_count":0,"language":"C++","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"halide:master","ref":"master","sha":"3616892f6af2aad4a2d725f365c1fcb7d4daf57f","user":{"login":"halide","id":1548551,"avatar_url":"https://avatars.githubusercontent.com/u/1548551?v=3","gravatar_id":"","url":"https://api.github.com/users/halide","html_url":"https://github.com/halide","followers_url":"https://api.github.com/users/halide/followers","following_url":"https://api.github.com/users/halide/following{/other_user}","gists_url":"https://api.github.com/users/halide/gists{/gist_id}","starred_url":"https://api.github.com/users/halide/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/halide/subscriptions","organizations_url":"https://api.github.com/users/halide/orgs","repos_url":"https://api.github.com/users/halide/repos","events_url":"https://api.github.com/users/halide/events{/privacy}","received_events_url":"https://api.github.com/users/halide/received_events","type":"Organization","site_admin":false},"repo":{"id":5241312,"name":"Halide","full_name":"halide/Halide","owner":{"login":"halide","id":1548551,"avatar_url":"https://avatars.githubusercontent.com/u/1548551?v=3","gravatar_id":"","url":"https://api.github.com/users/halide","html_url":"https://github.com/halide","followers_url":"https://api.github.com/users/halide/followers","following_url":"https://api.github.com/users/halide/following{/other_user}","gists_url":"https://api.github.com/users/halide/gists{/gist_id}","starred_url":"https://api.github.com/users/halide/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/halide/subscriptions","organizations_url":"https://api.github.com/users/halide/orgs","repos_url":"https://api.github.com/users/halide/repos","events_url":"https://api.github.com/users/halide/events{/privacy}","received_events_url":"https://api.github.com/users/halide/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/halide/Halide","description":"a language for image processing and computational photography","fork":false,"url":"https://api.github.com/repos/halide/Halide","forks_url":"https://api.github.com/repos/halide/Halide/forks","keys_url":"https://api.github.com/repos/halide/Halide/keys{/key_id}","collaborators_url":"https://api.github.com/repos/halide/Halide/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/halide/Halide/teams","hooks_url":"https://api.github.com/repos/halide/Halide/hooks","issue_events_url":"https://api.github.com/repos/halide/Halide/issues/events{/number}","events_url":"https://api.github.com/repos/halide/Halide/events","assignees_url":"https://api.github.com/repos/halide/Halide/assignees{/user}","branches_url":"https://api.github.com/repos/halide/Halide/branches{/branch}","tags_url":"https://api.github.com/repos/halide/Halide/tags","blobs_url":"https://api.github.com/repos/halide/Halide/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/halide/Halide/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/halide/Halide/git/refs{/sha}","trees_url":"https://api.github.com/repos/halide/Halide/git/trees{/sha}","statuses_url":"https://api.github.com/repos/halide/Halide/statuses/{sha}","languages_url":"https://api.github.com/repos/halide/Halide/languages","stargazers_url":"https://api.github.com/repos/halide/Halide/stargazers","contributors_url":"https://api.github.com/repos/halide/Halide/contributors","subscribers_url":"https://api.github.com/repos/halide/Halide/subscribers","subscription_url":"https://api.github.com/repos/halide/Halide/subscription","commits_url":"https://api.github.com/repos/halide/Halide/commits{/sha}","git_commits_url":"https://api.github.com/repos/halide/Halide/git/commits{/sha}","comments_url":"https://api.github.com/repos/halide/Halide/comments{/number}","issue_comment_url":"https://api.github.com/repos/halide/Halide/issues/comments{/number}","contents_url":"https://api.github.com/repos/halide/Halide/contents/{+path}","compare_url":"https://api.github.com/repos/halide/Halide/compare/{base}...{head}","merges_url":"https://api.github.com/repos/halide/Halide/merges","archive_url":"https://api.github.com/repos/halide/Halide/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/halide/Halide/downloads","issues_url":"https://api.github.com/repos/halide/Halide/issues{/number}","pulls_url":"https://api.github.com/repos/halide/Halide/pulls{/number}","milestones_url":"https://api.github.com/repos/halide/Halide/milestones{/number}","notifications_url":"https://api.github.com/repos/halide/Halide/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/halide/Halide/labels{/name}","releases_url":"https://api.github.com/repos/halide/Halide/releases{/id}","created_at":"2012-07-31T04:05:25Z","updated_at":"2015-05-06T01:55:35Z","pushed_at":"2015-05-06T01:55:35Z","git_url":"git://github.com/halide/Halide.git","ssh_url":"git@github.com:halide/Halide.git","clone_url":"https://github.com/halide/Halide.git","svn_url":"https://github.com/halide/Halide","homepage":"http://halide-lang.org","size":128456,"stargazers_count":949,"watchers_count":949,"language":"C++","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":173,"mirror_url":null,"open_issues_count":100,"forks":173,"open_issues":100,"watchers":949,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/halide/Halide/pulls/778"},"html":{"href":"https://github.com/halide/Halide/pull/778"},"issue":{"href":"https://api.github.com/repos/halide/Halide/issues/778"},"comments":{"href":"https://api.github.com/repos/halide/Halide/issues/778/comments"},"review_comments":{"href":"https://api.github.com/repos/halide/Halide/pulls/778/comments"},"review_comment":{"href":"https://api.github.com/repos/halide/Halide/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/halide/Halide/pulls/778/commits"},"statuses":{"href":"https://api.github.com/repos/halide/Halide/statuses/06447b132956933ef28b897701299b002a23dfe2"}}}}