{"action":"created","comment":{"url":"https://api.github.com/repos/WPIRoboticsProjects/GRIP/pulls/comments/46754846","id":46754846,"diff_hunk":"@@ -0,0 +1,84 @@\n+package edu.wpi.grip.ui.preview;\n+\n+import com.google.common.eventbus.EventBus;\n+import com.google.common.eventbus.Subscribe;\n+import edu.wpi.grip.core.OutputSocket;\n+import edu.wpi.grip.core.events.SocketChangedEvent;\n+import edu.wpi.grip.core.operations.composite.ContoursReport;\n+import edu.wpi.grip.ui.util.ImageConverter;\n+import javafx.application.Platform;\n+import javafx.scene.control.Label;\n+import javafx.scene.image.Image;\n+import javafx.scene.image.ImageView;\n+import javafx.scene.layout.VBox;\n+\n+import static org.bytedeco.javacpp.opencv_core.*;\n+import static org.bytedeco.javacpp.opencv_imgproc.drawContours;\n+\n+/**\n+ * A preview view for displaying contours.  This view shows each contour as a different-colored outline (so they can be\n+ * individually distinguished), as well as a count of the total number of contours found.\n+ */\n+public final class ContoursSocketPreviewView extends SocketPreviewView<ContoursReport> {\n+\n+    private final ImageConverter imageConverter = new ImageConverter();\n+    private final ImageView imageView = new ImageView();\n+    private final Label infoLabel = new Label();\n+    private final Mat tmp = new Mat();\n+\n+    private final static Scalar[] CONTOUR_COLORS = new Scalar[]{\n+            Scalar.RED,\n+            Scalar.YELLOW,\n+            Scalar.GREEN,\n+            Scalar.CYAN,\n+            Scalar.BLUE,\n+            Scalar.MAGENTA,\n+    };\n+\n+    /**\n+     * @param eventBus The EventBus used by the application\n+     * @param socket   An output socket to preview\n+     */\n+    public ContoursSocketPreviewView(EventBus eventBus, OutputSocket<ContoursReport> socket) {\n+        super(eventBus, socket);\n+\n+        this.setContent(new VBox(this.imageView, this.infoLabel));\n+        this.render();\n+    }\n+\n+    @Subscribe\n+    public void onSocketChanged(SocketChangedEvent event) {\n+        if (event.getSocket() == this.getSocket()) {\n+            this.render();\n+        }\n+    }\n+\n+    private void render() {\n+        synchronized (this) {\n+            final ContoursReport contours = this.getSocket().getValue().get();\n+            long numContours = 0;\n+\n+            if (!contours.getContours().isNull() && contours.getRows() > 0 && contours.getCols() > 0) {\n+                // Allocate a completely black OpenCV Mat to draw the contours onto.  We can easily render contours\n+                // by using OpenCV's drawContours function and converting the Mat into a JavaFX Image.\n+                this.tmp.create(contours.getRows(), contours.getCols(), CV_8UC3);\n+                bitwise_xor(tmp, tmp, tmp);\n+\n+                numContours = contours.getContours().size();\n+\n+                for (int i = 0; i < numContours; i++) {\n+                    drawContours(this.tmp, contours.getContours(), i, CONTOUR_COLORS[i % CONTOUR_COLORS.length]);","path":"ui/src/main/java/edu/wpi/grip/ui/preview/ContoursSocketPreviewView.java","position":70,"original_position":70,"commit_id":"22e8e852db79034ad9df97937ace0cde5b292c37","original_commit_id":"22e8e852db79034ad9df97937ace0cde5b292c37","user":{"login":"JLLeitschuh","id":1323708,"avatar_url":"https://avatars.githubusercontent.com/u/1323708?v=3","gravatar_id":"","url":"https://api.github.com/users/JLLeitschuh","html_url":"https://github.com/JLLeitschuh","followers_url":"https://api.github.com/users/JLLeitschuh/followers","following_url":"https://api.github.com/users/JLLeitschuh/following{/other_user}","gists_url":"https://api.github.com/users/JLLeitschuh/gists{/gist_id}","starred_url":"https://api.github.com/users/JLLeitschuh/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/JLLeitschuh/subscriptions","organizations_url":"https://api.github.com/users/JLLeitschuh/orgs","repos_url":"https://api.github.com/users/JLLeitschuh/repos","events_url":"https://api.github.com/users/JLLeitschuh/events{/privacy}","received_events_url":"https://api.github.com/users/JLLeitschuh/received_events","type":"User","site_admin":false},"body":"Because currently the contours flash arbitrarily. The colors should actually represent something.\r\nThis just looks bad and, again, epilepsy.","created_at":"2015-12-05T06:27:20Z","updated_at":"2015-12-05T06:27:20Z","html_url":"https://github.com/WPIRoboticsProjects/GRIP/pull/181#discussion_r46754846","pull_request_url":"https://api.github.com/repos/WPIRoboticsProjects/GRIP/pulls/181","_links":{"self":{"href":"https://api.github.com/repos/WPIRoboticsProjects/GRIP/pulls/comments/46754846"},"html":{"href":"https://github.com/WPIRoboticsProjects/GRIP/pull/181#discussion_r46754846"},"pull_request":{"href":"https://api.github.com/repos/WPIRoboticsProjects/GRIP/pulls/181"}}},"pull_request":{"url":"https://api.github.com/repos/WPIRoboticsProjects/GRIP/pulls/181","id":52623093,"html_url":"https://github.com/WPIRoboticsProjects/GRIP/pull/181","diff_url":"https://github.com/WPIRoboticsProjects/GRIP/pull/181.diff","patch_url":"https://github.com/WPIRoboticsProjects/GRIP/pull/181.patch","issue_url":"https://api.github.com/repos/WPIRoboticsProjects/GRIP/issues/181","number":181,"state":"open","locked":false,"title":"Add contour-related operations and examples","user":{"login":"ThomasJClark","id":3964980,"avatar_url":"https://avatars.githubusercontent.com/u/3964980?v=3","gravatar_id":"","url":"https://api.github.com/users/ThomasJClark","html_url":"https://github.com/ThomasJClark","followers_url":"https://api.github.com/users/ThomasJClark/followers","following_url":"https://api.github.com/users/ThomasJClark/following{/other_user}","gists_url":"https://api.github.com/users/ThomasJClark/gists{/gist_id}","starred_url":"https://api.github.com/users/ThomasJClark/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ThomasJClark/subscriptions","organizations_url":"https://api.github.com/users/ThomasJClark/orgs","repos_url":"https://api.github.com/users/ThomasJClark/repos","events_url":"https://api.github.com/users/ThomasJClark/events{/privacy}","received_events_url":"https://api.github.com/users/ThomasJClark/received_events","type":"User","site_admin":false},"body":"","created_at":"2015-12-04T02:36:47Z","updated_at":"2015-12-05T06:27:20Z","closed_at":null,"merged_at":null,"merge_commit_sha":"7ee68d584adcd0da37394f14b2a0e3edcdbb17f2","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/WPIRoboticsProjects/GRIP/pulls/181/commits","review_comments_url":"https://api.github.com/repos/WPIRoboticsProjects/GRIP/pulls/181/comments","review_comment_url":"https://api.github.com/repos/WPIRoboticsProjects/GRIP/pulls/comments{/number}","comments_url":"https://api.github.com/repos/WPIRoboticsProjects/GRIP/issues/181/comments","statuses_url":"https://api.github.com/repos/WPIRoboticsProjects/GRIP/statuses/22e8e852db79034ad9df97937ace0cde5b292c37","head":{"label":"ThomasJClark:contours","ref":"contours","sha":"22e8e852db79034ad9df97937ace0cde5b292c37","user":{"login":"ThomasJClark","id":3964980,"avatar_url":"https://avatars.githubusercontent.com/u/3964980?v=3","gravatar_id":"","url":"https://api.github.com/users/ThomasJClark","html_url":"https://github.com/ThomasJClark","followers_url":"https://api.github.com/users/ThomasJClark/followers","following_url":"https://api.github.com/users/ThomasJClark/following{/other_user}","gists_url":"https://api.github.com/users/ThomasJClark/gists{/gist_id}","starred_url":"https://api.github.com/users/ThomasJClark/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ThomasJClark/subscriptions","organizations_url":"https://api.github.com/users/ThomasJClark/orgs","repos_url":"https://api.github.com/users/ThomasJClark/repos","events_url":"https://api.github.com/users/ThomasJClark/events{/privacy}","received_events_url":"https://api.github.com/users/ThomasJClark/received_events","type":"User","site_admin":false},"repo":{"id":41703859,"name":"GRIP","full_name":"ThomasJClark/GRIP","owner":{"login":"ThomasJClark","id":3964980,"avatar_url":"https://avatars.githubusercontent.com/u/3964980?v=3","gravatar_id":"","url":"https://api.github.com/users/ThomasJClark","html_url":"https://github.com/ThomasJClark","followers_url":"https://api.github.com/users/ThomasJClark/followers","following_url":"https://api.github.com/users/ThomasJClark/following{/other_user}","gists_url":"https://api.github.com/users/ThomasJClark/gists{/gist_id}","starred_url":"https://api.github.com/users/ThomasJClark/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ThomasJClark/subscriptions","organizations_url":"https://api.github.com/users/ThomasJClark/orgs","repos_url":"https://api.github.com/users/ThomasJClark/repos","events_url":"https://api.github.com/users/ThomasJClark/events{/privacy}","received_events_url":"https://api.github.com/users/ThomasJClark/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/ThomasJClark/GRIP","description":"Program for rapidly developing computer vision applications","fork":true,"url":"https://api.github.com/repos/ThomasJClark/GRIP","forks_url":"https://api.github.com/repos/ThomasJClark/GRIP/forks","keys_url":"https://api.github.com/repos/ThomasJClark/GRIP/keys{/key_id}","collaborators_url":"https://api.github.com/repos/ThomasJClark/GRIP/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/ThomasJClark/GRIP/teams","hooks_url":"https://api.github.com/repos/ThomasJClark/GRIP/hooks","issue_events_url":"https://api.github.com/repos/ThomasJClark/GRIP/issues/events{/number}","events_url":"https://api.github.com/repos/ThomasJClark/GRIP/events","assignees_url":"https://api.github.com/repos/ThomasJClark/GRIP/assignees{/user}","branches_url":"https://api.github.com/repos/ThomasJClark/GRIP/branches{/branch}","tags_url":"https://api.github.com/repos/ThomasJClark/GRIP/tags","blobs_url":"https://api.github.com/repos/ThomasJClark/GRIP/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/ThomasJClark/GRIP/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/ThomasJClark/GRIP/git/refs{/sha}","trees_url":"https://api.github.com/repos/ThomasJClark/GRIP/git/trees{/sha}","statuses_url":"https://api.github.com/repos/ThomasJClark/GRIP/statuses/{sha}","languages_url":"https://api.github.com/repos/ThomasJClark/GRIP/languages","stargazers_url":"https://api.github.com/repos/ThomasJClark/GRIP/stargazers","contributors_url":"https://api.github.com/repos/ThomasJClark/GRIP/contributors","subscribers_url":"https://api.github.com/repos/ThomasJClark/GRIP/subscribers","subscription_url":"https://api.github.com/repos/ThomasJClark/GRIP/subscription","commits_url":"https://api.github.com/repos/ThomasJClark/GRIP/commits{/sha}","git_commits_url":"https://api.github.com/repos/ThomasJClark/GRIP/git/commits{/sha}","comments_url":"https://api.github.com/repos/ThomasJClark/GRIP/comments{/number}","issue_comment_url":"https://api.github.com/repos/ThomasJClark/GRIP/issues/comments{/number}","contents_url":"https://api.github.com/repos/ThomasJClark/GRIP/contents/{+path}","compare_url":"https://api.github.com/repos/ThomasJClark/GRIP/compare/{base}...{head}","merges_url":"https://api.github.com/repos/ThomasJClark/GRIP/merges","archive_url":"https://api.github.com/repos/ThomasJClark/GRIP/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/ThomasJClark/GRIP/downloads","issues_url":"https://api.github.com/repos/ThomasJClark/GRIP/issues{/number}","pulls_url":"https://api.github.com/repos/ThomasJClark/GRIP/pulls{/number}","milestones_url":"https://api.github.com/repos/ThomasJClark/GRIP/milestones{/number}","notifications_url":"https://api.github.com/repos/ThomasJClark/GRIP/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/ThomasJClark/GRIP/labels{/name}","releases_url":"https://api.github.com/repos/ThomasJClark/GRIP/releases{/id}","created_at":"2015-08-31T22:30:05Z","updated_at":"2015-10-07T03:27:13Z","pushed_at":"2015-12-05T06:21:48Z","git_url":"git://github.com/ThomasJClark/GRIP.git","ssh_url":"git@github.com:ThomasJClark/GRIP.git","clone_url":"https://github.com/ThomasJClark/GRIP.git","svn_url":"https://github.com/ThomasJClark/GRIP","homepage":"http://wpi.edu","size":2880,"stargazers_count":0,"watchers_count":0,"language":"Java","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":"WPIRoboticsProjects:master","ref":"master","sha":"800a607fbfa705edef789c85569196707e61450d","user":{"login":"WPIRoboticsProjects","id":14004340,"avatar_url":"https://avatars.githubusercontent.com/u/14004340?v=3","gravatar_id":"","url":"https://api.github.com/users/WPIRoboticsProjects","html_url":"https://github.com/WPIRoboticsProjects","followers_url":"https://api.github.com/users/WPIRoboticsProjects/followers","following_url":"https://api.github.com/users/WPIRoboticsProjects/following{/other_user}","gists_url":"https://api.github.com/users/WPIRoboticsProjects/gists{/gist_id}","starred_url":"https://api.github.com/users/WPIRoboticsProjects/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/WPIRoboticsProjects/subscriptions","organizations_url":"https://api.github.com/users/WPIRoboticsProjects/orgs","repos_url":"https://api.github.com/users/WPIRoboticsProjects/repos","events_url":"https://api.github.com/users/WPIRoboticsProjects/events{/privacy}","received_events_url":"https://api.github.com/users/WPIRoboticsProjects/received_events","type":"Organization","site_admin":false},"repo":{"id":41505521,"name":"GRIP","full_name":"WPIRoboticsProjects/GRIP","owner":{"login":"WPIRoboticsProjects","id":14004340,"avatar_url":"https://avatars.githubusercontent.com/u/14004340?v=3","gravatar_id":"","url":"https://api.github.com/users/WPIRoboticsProjects","html_url":"https://github.com/WPIRoboticsProjects","followers_url":"https://api.github.com/users/WPIRoboticsProjects/followers","following_url":"https://api.github.com/users/WPIRoboticsProjects/following{/other_user}","gists_url":"https://api.github.com/users/WPIRoboticsProjects/gists{/gist_id}","starred_url":"https://api.github.com/users/WPIRoboticsProjects/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/WPIRoboticsProjects/subscriptions","organizations_url":"https://api.github.com/users/WPIRoboticsProjects/orgs","repos_url":"https://api.github.com/users/WPIRoboticsProjects/repos","events_url":"https://api.github.com/users/WPIRoboticsProjects/events{/privacy}","received_events_url":"https://api.github.com/users/WPIRoboticsProjects/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/WPIRoboticsProjects/GRIP","description":"Program for rapidly developing computer vision applications","fork":false,"url":"https://api.github.com/repos/WPIRoboticsProjects/GRIP","forks_url":"https://api.github.com/repos/WPIRoboticsProjects/GRIP/forks","keys_url":"https://api.github.com/repos/WPIRoboticsProjects/GRIP/keys{/key_id}","collaborators_url":"https://api.github.com/repos/WPIRoboticsProjects/GRIP/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/WPIRoboticsProjects/GRIP/teams","hooks_url":"https://api.github.com/repos/WPIRoboticsProjects/GRIP/hooks","issue_events_url":"https://api.github.com/repos/WPIRoboticsProjects/GRIP/issues/events{/number}","events_url":"https://api.github.com/repos/WPIRoboticsProjects/GRIP/events","assignees_url":"https://api.github.com/repos/WPIRoboticsProjects/GRIP/assignees{/user}","branches_url":"https://api.github.com/repos/WPIRoboticsProjects/GRIP/branches{/branch}","tags_url":"https://api.github.com/repos/WPIRoboticsProjects/GRIP/tags","blobs_url":"https://api.github.com/repos/WPIRoboticsProjects/GRIP/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/WPIRoboticsProjects/GRIP/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/WPIRoboticsProjects/GRIP/git/refs{/sha}","trees_url":"https://api.github.com/repos/WPIRoboticsProjects/GRIP/git/trees{/sha}","statuses_url":"https://api.github.com/repos/WPIRoboticsProjects/GRIP/statuses/{sha}","languages_url":"https://api.github.com/repos/WPIRoboticsProjects/GRIP/languages","stargazers_url":"https://api.github.com/repos/WPIRoboticsProjects/GRIP/stargazers","contributors_url":"https://api.github.com/repos/WPIRoboticsProjects/GRIP/contributors","subscribers_url":"https://api.github.com/repos/WPIRoboticsProjects/GRIP/subscribers","subscription_url":"https://api.github.com/repos/WPIRoboticsProjects/GRIP/subscription","commits_url":"https://api.github.com/repos/WPIRoboticsProjects/GRIP/commits{/sha}","git_commits_url":"https://api.github.com/repos/WPIRoboticsProjects/GRIP/git/commits{/sha}","comments_url":"https://api.github.com/repos/WPIRoboticsProjects/GRIP/comments{/number}","issue_comment_url":"https://api.github.com/repos/WPIRoboticsProjects/GRIP/issues/comments{/number}","contents_url":"https://api.github.com/repos/WPIRoboticsProjects/GRIP/contents/{+path}","compare_url":"https://api.github.com/repos/WPIRoboticsProjects/GRIP/compare/{base}...{head}","merges_url":"https://api.github.com/repos/WPIRoboticsProjects/GRIP/merges","archive_url":"https://api.github.com/repos/WPIRoboticsProjects/GRIP/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/WPIRoboticsProjects/GRIP/downloads","issues_url":"https://api.github.com/repos/WPIRoboticsProjects/GRIP/issues{/number}","pulls_url":"https://api.github.com/repos/WPIRoboticsProjects/GRIP/pulls{/number}","milestones_url":"https://api.github.com/repos/WPIRoboticsProjects/GRIP/milestones{/number}","notifications_url":"https://api.github.com/repos/WPIRoboticsProjects/GRIP/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/WPIRoboticsProjects/GRIP/labels{/name}","releases_url":"https://api.github.com/repos/WPIRoboticsProjects/GRIP/releases{/id}","created_at":"2015-08-27T18:59:07Z","updated_at":"2015-11-26T20:27:28Z","pushed_at":"2015-12-05T02:30:25Z","git_url":"git://github.com/WPIRoboticsProjects/GRIP.git","ssh_url":"git@github.com:WPIRoboticsProjects/GRIP.git","clone_url":"https://github.com/WPIRoboticsProjects/GRIP.git","svn_url":"https://github.com/WPIRoboticsProjects/GRIP","homepage":"http://wpiroboticsprojects.github.io/GRIP","size":12184,"stargazers_count":23,"watchers_count":23,"language":"Java","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":7,"mirror_url":null,"open_issues_count":32,"forks":7,"open_issues":32,"watchers":23,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/WPIRoboticsProjects/GRIP/pulls/181"},"html":{"href":"https://github.com/WPIRoboticsProjects/GRIP/pull/181"},"issue":{"href":"https://api.github.com/repos/WPIRoboticsProjects/GRIP/issues/181"},"comments":{"href":"https://api.github.com/repos/WPIRoboticsProjects/GRIP/issues/181/comments"},"review_comments":{"href":"https://api.github.com/repos/WPIRoboticsProjects/GRIP/pulls/181/comments"},"review_comment":{"href":"https://api.github.com/repos/WPIRoboticsProjects/GRIP/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/WPIRoboticsProjects/GRIP/pulls/181/commits"},"statuses":{"href":"https://api.github.com/repos/WPIRoboticsProjects/GRIP/statuses/22e8e852db79034ad9df97937ace0cde5b292c37"}}}}