{"action":"created","comment":{"url":"https://api.github.com/repos/paparazzi/paparazzi/pulls/comments/68585466","id":68585466,"diff_hunk":"@@ -186,22 +206,73 @@ struct image_t *viewvideo_function(struct image_t *img)\n       // (1 = 1/90000 s) which is probably stupid but is actually working.\n     }\n #endif\n-\n   }\n \n   // Free all buffers\n   image_free(&img_jpeg);\n-  image_free(&img_small);\n-  return NULL; // No new images were created\n }\n \n+\n+void *viewvideo_thread(void *args);\n+void *viewvideo_thread(void *args) {\n+  // Time-keeping variables\n+  struct timespec time_now, time_prev;\n+  clock_gettime(CLOCK_MONOTONIC, &time_prev);\n+  int32_t delta = 0;\n+  uint32_t fps_period = 1000000 / VIEWVIDEO_FPS;\n+\n+  // Request new image from video thread\n+  pthread_mutex_lock(&img_mutex);","path":"sw/airborne/modules/computer_vision/viewvideo.c","position":128,"original_position":135,"commit_id":"3a0b1eb7aac28cd97d5be42781e3f6d2e900c647","original_commit_id":"685862075244cec494969d0bb2a525106da72a41","user":{"login":"flixr","id":104257,"avatar_url":"https://avatars.githubusercontent.com/u/104257?v=3","gravatar_id":"","url":"https://api.github.com/users/flixr","html_url":"https://github.com/flixr","followers_url":"https://api.github.com/users/flixr/followers","following_url":"https://api.github.com/users/flixr/following{/other_user}","gists_url":"https://api.github.com/users/flixr/gists{/gist_id}","starred_url":"https://api.github.com/users/flixr/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/flixr/subscriptions","organizations_url":"https://api.github.com/users/flixr/orgs","repos_url":"https://api.github.com/users/flixr/repos","events_url":"https://api.github.com/users/flixr/events{/privacy}","received_events_url":"https://api.github.com/users/flixr/received_events","type":"User","site_admin":false},"body":"Right, was badly phrased and I didn't have a close enough look (thought you were unlocking the mutex inside the while).\r\nThe above would still be the common usage pattern if you don't want/need to lock the mutex for the whole time, e.g if not the whole part is a critical section.","created_at":"2016-06-27T14:26:47Z","updated_at":"2016-06-27T14:26:47Z","html_url":"https://github.com/paparazzi/paparazzi/pull/1764#discussion_r68585466","pull_request_url":"https://api.github.com/repos/paparazzi/paparazzi/pulls/1764","_links":{"self":{"href":"https://api.github.com/repos/paparazzi/paparazzi/pulls/comments/68585466"},"html":{"href":"https://github.com/paparazzi/paparazzi/pull/1764#discussion_r68585466"},"pull_request":{"href":"https://api.github.com/repos/paparazzi/paparazzi/pulls/1764"}}},"pull_request":{"url":"https://api.github.com/repos/paparazzi/paparazzi/pulls/1764","id":75095340,"html_url":"https://github.com/paparazzi/paparazzi/pull/1764","diff_url":"https://github.com/paparazzi/paparazzi/pull/1764.diff","patch_url":"https://github.com/paparazzi/paparazzi/pull/1764.patch","issue_url":"https://api.github.com/repos/paparazzi/paparazzi/issues/1764","number":1764,"state":"open","locked":false,"title":"Threaded computer vision","user":{"login":"wilcoschoneveld","id":3064588,"avatar_url":"https://avatars.githubusercontent.com/u/3064588?v=3","gravatar_id":"","url":"https://api.github.com/users/wilcoschoneveld","html_url":"https://github.com/wilcoschoneveld","followers_url":"https://api.github.com/users/wilcoschoneveld/followers","following_url":"https://api.github.com/users/wilcoschoneveld/following{/other_user}","gists_url":"https://api.github.com/users/wilcoschoneveld/gists{/gist_id}","starred_url":"https://api.github.com/users/wilcoschoneveld/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/wilcoschoneveld/subscriptions","organizations_url":"https://api.github.com/users/wilcoschoneveld/orgs","repos_url":"https://api.github.com/users/wilcoschoneveld/repos","events_url":"https://api.github.com/users/wilcoschoneveld/events{/privacy}","received_events_url":"https://api.github.com/users/wilcoschoneveld/received_events","type":"User","site_admin":false},"body":"This pull request addresses improved computer vision functionality as discussed in #1735.\r\n\r\nQuick recap; There is a desire to have some vision functions run with less fps than others. It would be great if the priorities can be set between vision functions. For example, textons should run at 5 Hz and optical flow at 30 Hz.\r\n\r\nThe current setup; For each video device a vision pipeline is created. Modules can attach to this pipeline and process the image in turn, and even modify the image. For example, a color filter can modify the image and one can then view the result in RTP stream. The problem is that, since the vision pipeline is sequential, some modules (like a costly marker detection algorithm) can stall the performance of other vision functions.\r\n\r\nI made a proof of concept with @flixr's suggestion in the video_rtp_stream module. The module attaches to the vision pipeline with a routine that copies the image to a buffer if required. The module processes and sends the frames in a separate thread at 10 Hz.\r\n\r\nTODO:\r\n- Abstract thread functionality into cv.h\r\n- Improve thread managing (starting/stopping module)\r\n\r\nI think overall this is a good approach, but there are some drawbacks;\r\n- Copying the image costs time\r\n- The modified image is lost","created_at":"2016-06-24T10:36:19Z","updated_at":"2016-06-27T14:26:47Z","closed_at":null,"merged_at":null,"merge_commit_sha":"0a7c6ee02ab095cea1c269e0b59a0f166707d543","assignee":null,"assignees":[],"milestone":null,"commits_url":"https://api.github.com/repos/paparazzi/paparazzi/pulls/1764/commits","review_comments_url":"https://api.github.com/repos/paparazzi/paparazzi/pulls/1764/comments","review_comment_url":"https://api.github.com/repos/paparazzi/paparazzi/pulls/comments{/number}","comments_url":"https://api.github.com/repos/paparazzi/paparazzi/issues/1764/comments","statuses_url":"https://api.github.com/repos/paparazzi/paparazzi/statuses/3a0b1eb7aac28cd97d5be42781e3f6d2e900c647","head":{"label":"wilcoschoneveld:threaded_vision","ref":"threaded_vision","sha":"3a0b1eb7aac28cd97d5be42781e3f6d2e900c647","user":{"login":"wilcoschoneveld","id":3064588,"avatar_url":"https://avatars.githubusercontent.com/u/3064588?v=3","gravatar_id":"","url":"https://api.github.com/users/wilcoschoneveld","html_url":"https://github.com/wilcoschoneveld","followers_url":"https://api.github.com/users/wilcoschoneveld/followers","following_url":"https://api.github.com/users/wilcoschoneveld/following{/other_user}","gists_url":"https://api.github.com/users/wilcoschoneveld/gists{/gist_id}","starred_url":"https://api.github.com/users/wilcoschoneveld/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/wilcoschoneveld/subscriptions","organizations_url":"https://api.github.com/users/wilcoschoneveld/orgs","repos_url":"https://api.github.com/users/wilcoschoneveld/repos","events_url":"https://api.github.com/users/wilcoschoneveld/events{/privacy}","received_events_url":"https://api.github.com/users/wilcoschoneveld/received_events","type":"User","site_admin":false},"repo":{"id":58475026,"name":"paparazzi","full_name":"wilcoschoneveld/paparazzi","owner":{"login":"wilcoschoneveld","id":3064588,"avatar_url":"https://avatars.githubusercontent.com/u/3064588?v=3","gravatar_id":"","url":"https://api.github.com/users/wilcoschoneveld","html_url":"https://github.com/wilcoschoneveld","followers_url":"https://api.github.com/users/wilcoschoneveld/followers","following_url":"https://api.github.com/users/wilcoschoneveld/following{/other_user}","gists_url":"https://api.github.com/users/wilcoschoneveld/gists{/gist_id}","starred_url":"https://api.github.com/users/wilcoschoneveld/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/wilcoschoneveld/subscriptions","organizations_url":"https://api.github.com/users/wilcoschoneveld/orgs","repos_url":"https://api.github.com/users/wilcoschoneveld/repos","events_url":"https://api.github.com/users/wilcoschoneveld/events{/privacy}","received_events_url":"https://api.github.com/users/wilcoschoneveld/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/wilcoschoneveld/paparazzi","description":"Paparazzi is a free and open-source hardware and software project for unmanned (air) vehicles.","fork":true,"url":"https://api.github.com/repos/wilcoschoneveld/paparazzi","forks_url":"https://api.github.com/repos/wilcoschoneveld/paparazzi/forks","keys_url":"https://api.github.com/repos/wilcoschoneveld/paparazzi/keys{/key_id}","collaborators_url":"https://api.github.com/repos/wilcoschoneveld/paparazzi/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/wilcoschoneveld/paparazzi/teams","hooks_url":"https://api.github.com/repos/wilcoschoneveld/paparazzi/hooks","issue_events_url":"https://api.github.com/repos/wilcoschoneveld/paparazzi/issues/events{/number}","events_url":"https://api.github.com/repos/wilcoschoneveld/paparazzi/events","assignees_url":"https://api.github.com/repos/wilcoschoneveld/paparazzi/assignees{/user}","branches_url":"https://api.github.com/repos/wilcoschoneveld/paparazzi/branches{/branch}","tags_url":"https://api.github.com/repos/wilcoschoneveld/paparazzi/tags","blobs_url":"https://api.github.com/repos/wilcoschoneveld/paparazzi/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/wilcoschoneveld/paparazzi/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/wilcoschoneveld/paparazzi/git/refs{/sha}","trees_url":"https://api.github.com/repos/wilcoschoneveld/paparazzi/git/trees{/sha}","statuses_url":"https://api.github.com/repos/wilcoschoneveld/paparazzi/statuses/{sha}","languages_url":"https://api.github.com/repos/wilcoschoneveld/paparazzi/languages","stargazers_url":"https://api.github.com/repos/wilcoschoneveld/paparazzi/stargazers","contributors_url":"https://api.github.com/repos/wilcoschoneveld/paparazzi/contributors","subscribers_url":"https://api.github.com/repos/wilcoschoneveld/paparazzi/subscribers","subscription_url":"https://api.github.com/repos/wilcoschoneveld/paparazzi/subscription","commits_url":"https://api.github.com/repos/wilcoschoneveld/paparazzi/commits{/sha}","git_commits_url":"https://api.github.com/repos/wilcoschoneveld/paparazzi/git/commits{/sha}","comments_url":"https://api.github.com/repos/wilcoschoneveld/paparazzi/comments{/number}","issue_comment_url":"https://api.github.com/repos/wilcoschoneveld/paparazzi/issues/comments{/number}","contents_url":"https://api.github.com/repos/wilcoschoneveld/paparazzi/contents/{+path}","compare_url":"https://api.github.com/repos/wilcoschoneveld/paparazzi/compare/{base}...{head}","merges_url":"https://api.github.com/repos/wilcoschoneveld/paparazzi/merges","archive_url":"https://api.github.com/repos/wilcoschoneveld/paparazzi/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/wilcoschoneveld/paparazzi/downloads","issues_url":"https://api.github.com/repos/wilcoschoneveld/paparazzi/issues{/number}","pulls_url":"https://api.github.com/repos/wilcoschoneveld/paparazzi/pulls{/number}","milestones_url":"https://api.github.com/repos/wilcoschoneveld/paparazzi/milestones{/number}","notifications_url":"https://api.github.com/repos/wilcoschoneveld/paparazzi/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/wilcoschoneveld/paparazzi/labels{/name}","releases_url":"https://api.github.com/repos/wilcoschoneveld/paparazzi/releases{/id}","deployments_url":"https://api.github.com/repos/wilcoschoneveld/paparazzi/deployments","created_at":"2016-05-10T15:58:47Z","updated_at":"2016-06-21T16:42:28Z","pushed_at":"2016-06-27T13:45:56Z","git_url":"git://github.com/wilcoschoneveld/paparazzi.git","ssh_url":"git@github.com:wilcoschoneveld/paparazzi.git","clone_url":"https://github.com/wilcoschoneveld/paparazzi.git","svn_url":"https://github.com/wilcoschoneveld/paparazzi","homepage":"http://paparazziuav.org","size":69376,"stargazers_count":0,"watchers_count":0,"language":"C","has_issues":false,"has_downloads":true,"has_wiki":false,"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":"paparazzi:master","ref":"master","sha":"c1c48c21846a1f9dc209432f97653f1ffaa3edf2","user":{"login":"paparazzi","id":318080,"avatar_url":"https://avatars.githubusercontent.com/u/318080?v=3","gravatar_id":"","url":"https://api.github.com/users/paparazzi","html_url":"https://github.com/paparazzi","followers_url":"https://api.github.com/users/paparazzi/followers","following_url":"https://api.github.com/users/paparazzi/following{/other_user}","gists_url":"https://api.github.com/users/paparazzi/gists{/gist_id}","starred_url":"https://api.github.com/users/paparazzi/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/paparazzi/subscriptions","organizations_url":"https://api.github.com/users/paparazzi/orgs","repos_url":"https://api.github.com/users/paparazzi/repos","events_url":"https://api.github.com/users/paparazzi/events{/privacy}","received_events_url":"https://api.github.com/users/paparazzi/received_events","type":"Organization","site_admin":false},"repo":{"id":1068018,"name":"paparazzi","full_name":"paparazzi/paparazzi","owner":{"login":"paparazzi","id":318080,"avatar_url":"https://avatars.githubusercontent.com/u/318080?v=3","gravatar_id":"","url":"https://api.github.com/users/paparazzi","html_url":"https://github.com/paparazzi","followers_url":"https://api.github.com/users/paparazzi/followers","following_url":"https://api.github.com/users/paparazzi/following{/other_user}","gists_url":"https://api.github.com/users/paparazzi/gists{/gist_id}","starred_url":"https://api.github.com/users/paparazzi/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/paparazzi/subscriptions","organizations_url":"https://api.github.com/users/paparazzi/orgs","repos_url":"https://api.github.com/users/paparazzi/repos","events_url":"https://api.github.com/users/paparazzi/events{/privacy}","received_events_url":"https://api.github.com/users/paparazzi/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/paparazzi/paparazzi","description":"Paparazzi is a free and open-source hardware and software project for unmanned (air) vehicles. This is the main software repository.","fork":false,"url":"https://api.github.com/repos/paparazzi/paparazzi","forks_url":"https://api.github.com/repos/paparazzi/paparazzi/forks","keys_url":"https://api.github.com/repos/paparazzi/paparazzi/keys{/key_id}","collaborators_url":"https://api.github.com/repos/paparazzi/paparazzi/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/paparazzi/paparazzi/teams","hooks_url":"https://api.github.com/repos/paparazzi/paparazzi/hooks","issue_events_url":"https://api.github.com/repos/paparazzi/paparazzi/issues/events{/number}","events_url":"https://api.github.com/repos/paparazzi/paparazzi/events","assignees_url":"https://api.github.com/repos/paparazzi/paparazzi/assignees{/user}","branches_url":"https://api.github.com/repos/paparazzi/paparazzi/branches{/branch}","tags_url":"https://api.github.com/repos/paparazzi/paparazzi/tags","blobs_url":"https://api.github.com/repos/paparazzi/paparazzi/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/paparazzi/paparazzi/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/paparazzi/paparazzi/git/refs{/sha}","trees_url":"https://api.github.com/repos/paparazzi/paparazzi/git/trees{/sha}","statuses_url":"https://api.github.com/repos/paparazzi/paparazzi/statuses/{sha}","languages_url":"https://api.github.com/repos/paparazzi/paparazzi/languages","stargazers_url":"https://api.github.com/repos/paparazzi/paparazzi/stargazers","contributors_url":"https://api.github.com/repos/paparazzi/paparazzi/contributors","subscribers_url":"https://api.github.com/repos/paparazzi/paparazzi/subscribers","subscription_url":"https://api.github.com/repos/paparazzi/paparazzi/subscription","commits_url":"https://api.github.com/repos/paparazzi/paparazzi/commits{/sha}","git_commits_url":"https://api.github.com/repos/paparazzi/paparazzi/git/commits{/sha}","comments_url":"https://api.github.com/repos/paparazzi/paparazzi/comments{/number}","issue_comment_url":"https://api.github.com/repos/paparazzi/paparazzi/issues/comments{/number}","contents_url":"https://api.github.com/repos/paparazzi/paparazzi/contents/{+path}","compare_url":"https://api.github.com/repos/paparazzi/paparazzi/compare/{base}...{head}","merges_url":"https://api.github.com/repos/paparazzi/paparazzi/merges","archive_url":"https://api.github.com/repos/paparazzi/paparazzi/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/paparazzi/paparazzi/downloads","issues_url":"https://api.github.com/repos/paparazzi/paparazzi/issues{/number}","pulls_url":"https://api.github.com/repos/paparazzi/paparazzi/pulls{/number}","milestones_url":"https://api.github.com/repos/paparazzi/paparazzi/milestones{/number}","notifications_url":"https://api.github.com/repos/paparazzi/paparazzi/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/paparazzi/paparazzi/labels{/name}","releases_url":"https://api.github.com/repos/paparazzi/paparazzi/releases{/id}","deployments_url":"https://api.github.com/repos/paparazzi/paparazzi/deployments","created_at":"2010-11-10T11:14:08Z","updated_at":"2016-06-27T01:46:52Z","pushed_at":"2016-06-27T14:07:42Z","git_url":"git://github.com/paparazzi/paparazzi.git","ssh_url":"git@github.com:paparazzi/paparazzi.git","clone_url":"https://github.com/paparazzi/paparazzi.git","svn_url":"https://github.com/paparazzi/paparazzi","homepage":"http://paparazziuav.org","size":100537,"stargazers_count":585,"watchers_count":585,"language":"C","has_issues":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":610,"mirror_url":null,"open_issues_count":117,"forks":610,"open_issues":117,"watchers":585,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/paparazzi/paparazzi/pulls/1764"},"html":{"href":"https://github.com/paparazzi/paparazzi/pull/1764"},"issue":{"href":"https://api.github.com/repos/paparazzi/paparazzi/issues/1764"},"comments":{"href":"https://api.github.com/repos/paparazzi/paparazzi/issues/1764/comments"},"review_comments":{"href":"https://api.github.com/repos/paparazzi/paparazzi/pulls/1764/comments"},"review_comment":{"href":"https://api.github.com/repos/paparazzi/paparazzi/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/paparazzi/paparazzi/pulls/1764/commits"},"statuses":{"href":"https://api.github.com/repos/paparazzi/paparazzi/statuses/3a0b1eb7aac28cd97d5be42781e3f6d2e900c647"}}}}
{"actor":{"display_login":"flixr"}}