{"action":"created","comment":{"url":"https://api.github.com/repos/WPIRoboticsProjects/GRIP/pulls/comments/61107715","id":61107715,"diff_hunk":"@@ -0,0 +1,171 @@\n+package edu.wpi.grip.core.operations.composite;\n+\n+import com.google.common.eventbus.EventBus;\n+import edu.wpi.grip.core.sockets.InputSocket;\n+import edu.wpi.grip.core.Operation;\n+import edu.wpi.grip.core.sockets.OutputSocket;\n+import edu.wpi.grip.core.sockets.SocketHints;\n+import org.bytedeco.javacpp.BytePointer;\n+import org.bytedeco.javacpp.IntPointer;\n+\n+import java.io.FileOutputStream;\n+import java.io.IOException;\n+import java.io.InputStream;\n+import java.text.SimpleDateFormat;\n+import java.util.Date;\n+import java.util.Optional;\n+import java.util.Properties;\n+import java.util.logging.Level;\n+import java.util.logging.Logger;\n+\n+import static org.bytedeco.javacpp.opencv_core.Mat;\n+import static org.bytedeco.javacpp.opencv_imgcodecs.CV_IMWRITE_JPEG_QUALITY;\n+import static org.bytedeco.javacpp.opencv_imgcodecs.imencode;\n+\n+/**\n+ * Save JPEG files periodically to the local disk.\n+ */\n+public class SaveImageOperation implements Operation {\n+\n+    private final Logger logger = Logger.getLogger(SaveImageOperation.class.getName());\n+\n+    private final Object imageLock = new Object();\n+    private final BytePointer imagePointer = new BytePointer();\n+    private Optional<Thread> saveThread = Optional.empty();\n+    private volatile boolean connected = false;\n+    private long startTime = System.nanoTime();","path":"core/src/main/java/edu/wpi/grip/core/operations/composite/SaveImageOperation.java","position":36,"original_position":36,"commit_id":"d3cc497477626a3d8afe2e314920f082543446fb","original_commit_id":"d3cc497477626a3d8afe2e314920f082543446fb","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":"Guava has the [stopwatch](http://docs.guava-libraries.googlecode.com/git/javadoc/com/google/common/base/Stopwatch.html) that may be more apropreate here. Up to you though.","created_at":"2016-04-26T15:30:28Z","updated_at":"2016-04-26T15:30:28Z","html_url":"https://github.com/WPIRoboticsProjects/GRIP/pull/573#discussion_r61107715","pull_request_url":"https://api.github.com/repos/WPIRoboticsProjects/GRIP/pulls/573","_links":{"self":{"href":"https://api.github.com/repos/WPIRoboticsProjects/GRIP/pulls/comments/61107715"},"html":{"href":"https://github.com/WPIRoboticsProjects/GRIP/pull/573#discussion_r61107715"},"pull_request":{"href":"https://api.github.com/repos/WPIRoboticsProjects/GRIP/pulls/573"}}},"pull_request":{"url":"https://api.github.com/repos/WPIRoboticsProjects/GRIP/pulls/573","id":67599144,"html_url":"https://github.com/WPIRoboticsProjects/GRIP/pull/573","diff_url":"https://github.com/WPIRoboticsProjects/GRIP/pull/573.diff","patch_url":"https://github.com/WPIRoboticsProjects/GRIP/pull/573.patch","issue_url":"https://api.github.com/repos/WPIRoboticsProjects/GRIP/issues/573","number":573,"state":"open","locked":false,"title":"Add operation to save image snapshots to local disk.","user":{"login":"PeterJohnson","id":297126,"avatar_url":"https://avatars.githubusercontent.com/u/297126?v=3","gravatar_id":"","url":"https://api.github.com/users/PeterJohnson","html_url":"https://github.com/PeterJohnson","followers_url":"https://api.github.com/users/PeterJohnson/followers","following_url":"https://api.github.com/users/PeterJohnson/following{/other_user}","gists_url":"https://api.github.com/users/PeterJohnson/gists{/gist_id}","starred_url":"https://api.github.com/users/PeterJohnson/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/PeterJohnson/subscriptions","organizations_url":"https://api.github.com/users/PeterJohnson/orgs","repos_url":"https://api.github.com/users/PeterJohnson/repos","events_url":"https://api.github.com/users/PeterJohnson/events{/privacy}","received_events_url":"https://api.github.com/users/PeterJohnson/received_events","type":"User","site_admin":false},"body":"The period and path prefix and suffix can be set, and the operation enabled\r\nand disabled at will (this is particularly useful in combination with PR #572).","created_at":"2016-04-23T07:18:02Z","updated_at":"2016-04-26T15:30:28Z","closed_at":null,"merged_at":null,"merge_commit_sha":"a605830b603177065b53a2dfe07d5eee1359dd7f","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/WPIRoboticsProjects/GRIP/pulls/573/commits","review_comments_url":"https://api.github.com/repos/WPIRoboticsProjects/GRIP/pulls/573/comments","review_comment_url":"https://api.github.com/repos/WPIRoboticsProjects/GRIP/pulls/comments{/number}","comments_url":"https://api.github.com/repos/WPIRoboticsProjects/GRIP/issues/573/comments","statuses_url":"https://api.github.com/repos/WPIRoboticsProjects/GRIP/statuses/d3cc497477626a3d8afe2e314920f082543446fb","head":{"label":"team294:image-snapshots","ref":"image-snapshots","sha":"d3cc497477626a3d8afe2e314920f082543446fb","user":{"login":"team294","id":2513444,"avatar_url":"https://avatars.githubusercontent.com/u/2513444?v=3","gravatar_id":"","url":"https://api.github.com/users/team294","html_url":"https://github.com/team294","followers_url":"https://api.github.com/users/team294/followers","following_url":"https://api.github.com/users/team294/following{/other_user}","gists_url":"https://api.github.com/users/team294/gists{/gist_id}","starred_url":"https://api.github.com/users/team294/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/team294/subscriptions","organizations_url":"https://api.github.com/users/team294/orgs","repos_url":"https://api.github.com/users/team294/repos","events_url":"https://api.github.com/users/team294/events{/privacy}","received_events_url":"https://api.github.com/users/team294/received_events","type":"Organization","site_admin":false},"repo":{"id":56736626,"name":"GRIP","full_name":"team294/GRIP","owner":{"login":"team294","id":2513444,"avatar_url":"https://avatars.githubusercontent.com/u/2513444?v=3","gravatar_id":"","url":"https://api.github.com/users/team294","html_url":"https://github.com/team294","followers_url":"https://api.github.com/users/team294/followers","following_url":"https://api.github.com/users/team294/following{/other_user}","gists_url":"https://api.github.com/users/team294/gists{/gist_id}","starred_url":"https://api.github.com/users/team294/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/team294/subscriptions","organizations_url":"https://api.github.com/users/team294/orgs","repos_url":"https://api.github.com/users/team294/repos","events_url":"https://api.github.com/users/team294/events{/privacy}","received_events_url":"https://api.github.com/users/team294/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/team294/GRIP","description":"Program for rapidly developing computer vision applications","fork":true,"url":"https://api.github.com/repos/team294/GRIP","forks_url":"https://api.github.com/repos/team294/GRIP/forks","keys_url":"https://api.github.com/repos/team294/GRIP/keys{/key_id}","collaborators_url":"https://api.github.com/repos/team294/GRIP/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/team294/GRIP/teams","hooks_url":"https://api.github.com/repos/team294/GRIP/hooks","issue_events_url":"https://api.github.com/repos/team294/GRIP/issues/events{/number}","events_url":"https://api.github.com/repos/team294/GRIP/events","assignees_url":"https://api.github.com/repos/team294/GRIP/assignees{/user}","branches_url":"https://api.github.com/repos/team294/GRIP/branches{/branch}","tags_url":"https://api.github.com/repos/team294/GRIP/tags","blobs_url":"https://api.github.com/repos/team294/GRIP/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/team294/GRIP/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/team294/GRIP/git/refs{/sha}","trees_url":"https://api.github.com/repos/team294/GRIP/git/trees{/sha}","statuses_url":"https://api.github.com/repos/team294/GRIP/statuses/{sha}","languages_url":"https://api.github.com/repos/team294/GRIP/languages","stargazers_url":"https://api.github.com/repos/team294/GRIP/stargazers","contributors_url":"https://api.github.com/repos/team294/GRIP/contributors","subscribers_url":"https://api.github.com/repos/team294/GRIP/subscribers","subscription_url":"https://api.github.com/repos/team294/GRIP/subscription","commits_url":"https://api.github.com/repos/team294/GRIP/commits{/sha}","git_commits_url":"https://api.github.com/repos/team294/GRIP/git/commits{/sha}","comments_url":"https://api.github.com/repos/team294/GRIP/comments{/number}","issue_comment_url":"https://api.github.com/repos/team294/GRIP/issues/comments{/number}","contents_url":"https://api.github.com/repos/team294/GRIP/contents/{+path}","compare_url":"https://api.github.com/repos/team294/GRIP/compare/{base}...{head}","merges_url":"https://api.github.com/repos/team294/GRIP/merges","archive_url":"https://api.github.com/repos/team294/GRIP/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/team294/GRIP/downloads","issues_url":"https://api.github.com/repos/team294/GRIP/issues{/number}","pulls_url":"https://api.github.com/repos/team294/GRIP/pulls{/number}","milestones_url":"https://api.github.com/repos/team294/GRIP/milestones{/number}","notifications_url":"https://api.github.com/repos/team294/GRIP/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/team294/GRIP/labels{/name}","releases_url":"https://api.github.com/repos/team294/GRIP/releases{/id}","deployments_url":"https://api.github.com/repos/team294/GRIP/deployments","created_at":"2016-04-21T02:34:32Z","updated_at":"2016-04-21T02:34:34Z","pushed_at":"2016-04-23T07:21:16Z","git_url":"git://github.com/team294/GRIP.git","ssh_url":"git@github.com:team294/GRIP.git","clone_url":"https://github.com/team294/GRIP.git","svn_url":"https://github.com/team294/GRIP","homepage":"http://wpiroboticsprojects.github.io/GRIP","size":42782,"stargazers_count":0,"watchers_count":0,"language":"Java","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"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":"18a7a4ad86227a3e4996ab3393ef96247878258d","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}","deployments_url":"https://api.github.com/repos/WPIRoboticsProjects/GRIP/deployments","created_at":"2015-08-27T18:59:07Z","updated_at":"2016-04-15T15:15:17Z","pushed_at":"2016-04-26T00:30:22Z","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":46488,"stargazers_count":102,"watchers_count":102,"language":"Java","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":42,"mirror_url":null,"open_issues_count":97,"forks":42,"open_issues":97,"watchers":102,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/WPIRoboticsProjects/GRIP/pulls/573"},"html":{"href":"https://github.com/WPIRoboticsProjects/GRIP/pull/573"},"issue":{"href":"https://api.github.com/repos/WPIRoboticsProjects/GRIP/issues/573"},"comments":{"href":"https://api.github.com/repos/WPIRoboticsProjects/GRIP/issues/573/comments"},"review_comments":{"href":"https://api.github.com/repos/WPIRoboticsProjects/GRIP/pulls/573/comments"},"review_comment":{"href":"https://api.github.com/repos/WPIRoboticsProjects/GRIP/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/WPIRoboticsProjects/GRIP/pulls/573/commits"},"statuses":{"href":"https://api.github.com/repos/WPIRoboticsProjects/GRIP/statuses/d3cc497477626a3d8afe2e314920f082543446fb"}}}}