{"action":"created","comment":{"url":"https://api.github.com/repos/Foxiy/board2slides/pulls/comments/47702333","id":47702333,"diff_hunk":"@@ -0,0 +1,142 @@\n+#!/usr/bin/env python\n+import sys\n+import cv2 as cv\n+import numpy as np\n+import ntpath\n+import functools\n+import time\n+\n+\n+def timeit(func):\n+    \"\"\"\n+    Poors man profiling function to\n+    measure time it takes to finish function.\n+    \"\"\"\n+    @functools.wraps(func)\n+    def newfunc(*args, **kwargs):\n+        start_time = time.time()\n+        out = func(*args, **kwargs)\n+        elapsed_time = time.time() - start_time\n+        msg = 'function [{}] finished in {} ms'\n+        print(msg.format(func.__name__, int(elapsed_time * 1000)))\n+        return out\n+    return newfunc\n+\n+\n+class BoardToolkit:\n+    def __init__(self, lo_thresh=100, hi_thresh=255):\n+        self.lo_thresh = lo_thresh\n+        self.hi_thresh = hi_thresh\n+\n+    def __get_index(self, arr):\n+        \"\"\"\n+        Function for returning min, max tuples from\n+        our arrays.\n+        \"\"\"\n+        max = np.argmax(arr)\n+        min = np.argmin(arr)\n+        return (min, max)\n+\n+    def calc_hist(self, image):\n+        \"\"\"\n+        Function gets rid of low intensity pixels values in\n+        color spectrum and sets them to 0. Then it calculates\n+        histogram of green color in x and y axis from image.\n+        Then we calculate 1-th order difference on this\n+        histogram and return min and max value indexes.\n+        \"\"\"\n+        (width, height, _) = image.shape\n+        vlines = np.zeros(width)\n+        hlines = np.zeros(height)\n+        image[:, :, 1] = cv.inRange(image[:, :, 1],\n+                                    self.lo_thresh,\n+                                    self.hi_thresh)\n+        vlines = cv.reduce(image[:, :, 1], 1,\n+                           cv.cv.CV_REDUCE_SUM,\n+                           dtype=cv.CV_32S)\n+        hlines = cv.reduce(image[:, :, 1], 0,\n+                           cv.cv.CV_REDUCE_SUM,\n+                           dtype=cv.CV_32S)\n+        y = np.diff(map(lambda *row: list(row), *vlines)[0])\n+        x = np.diff(hlines[0])\n+        return (self.__get_index(x), self.__get_index(y))\n+\n+    def get_table_metadata(self, image):","path":"toolkit.py","position":64,"original_position":64,"commit_id":"bda8cdf8068db9c89fd6062bad605d23a5d84048","original_commit_id":"bda8cdf8068db9c89fd6062bad605d23a5d84048","user":{"login":"Foxiy","id":9467741,"avatar_url":"https://avatars.githubusercontent.com/u/9467741?v=3","gravatar_id":"","url":"https://api.github.com/users/Foxiy","html_url":"https://github.com/Foxiy","followers_url":"https://api.github.com/users/Foxiy/followers","following_url":"https://api.github.com/users/Foxiy/following{/other_user}","gists_url":"https://api.github.com/users/Foxiy/gists{/gist_id}","starred_url":"https://api.github.com/users/Foxiy/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Foxiy/subscriptions","organizations_url":"https://api.github.com/users/Foxiy/orgs","repos_url":"https://api.github.com/users/Foxiy/repos","events_url":"https://api.github.com/users/Foxiy/events{/privacy}","received_events_url":"https://api.github.com/users/Foxiy/received_events","type":"User","site_admin":false},"body":"@mrshu Yes I'm planing to add some method for unifying a colours something like this http://stackoverflow.com/questions/16895135/getting-dominance-color-opencv and then somehow determine if there is a whiteboard or blackboard on the picture","created_at":"2015-12-15T21:36:44Z","updated_at":"2015-12-15T21:36:44Z","html_url":"https://github.com/Foxiy/board2slides/pull/18#discussion_r47702333","pull_request_url":"https://api.github.com/repos/Foxiy/board2slides/pulls/18","_links":{"self":{"href":"https://api.github.com/repos/Foxiy/board2slides/pulls/comments/47702333"},"html":{"href":"https://github.com/Foxiy/board2slides/pull/18#discussion_r47702333"},"pull_request":{"href":"https://api.github.com/repos/Foxiy/board2slides/pulls/18"}}},"pull_request":{"url":"https://api.github.com/repos/Foxiy/board2slides/pulls/18","id":48690103,"html_url":"https://github.com/Foxiy/board2slides/pull/18","diff_url":"https://github.com/Foxiy/board2slides/pull/18.diff","patch_url":"https://github.com/Foxiy/board2slides/pull/18.patch","issue_url":"https://api.github.com/repos/Foxiy/board2slides/issues/18","number":18,"state":"open","locked":false,"title":"update: Added toolkit class for dataset making","user":{"login":"Foxiy","id":9467741,"avatar_url":"https://avatars.githubusercontent.com/u/9467741?v=3","gravatar_id":"","url":"https://api.github.com/users/Foxiy","html_url":"https://github.com/Foxiy","followers_url":"https://api.github.com/users/Foxiy/followers","following_url":"https://api.github.com/users/Foxiy/following{/other_user}","gists_url":"https://api.github.com/users/Foxiy/gists{/gist_id}","starred_url":"https://api.github.com/users/Foxiy/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Foxiy/subscriptions","organizations_url":"https://api.github.com/users/Foxiy/orgs","repos_url":"https://api.github.com/users/Foxiy/repos","events_url":"https://api.github.com/users/Foxiy/events{/privacy}","received_events_url":"https://api.github.com/users/Foxiy/received_events","type":"User","site_admin":false},"body":"* toolkit.py - Create new class for creating metadata\r\n               from images or videos. It loads a file\r\n               tries to find a board with modify version\r\n               of our first histogram algorithm. This version\r\n               is faster but a bit less accurate. Then\r\n               it prints found values of boards corners\r\n               to a file with frame indexes.\r\n\r\n* project.py - refactoring to fit pep standards","created_at":"2015-10-25T22:44:51Z","updated_at":"2015-12-15T21:36:44Z","closed_at":null,"merged_at":null,"merge_commit_sha":"9179d1b1e7a7adb898c32cf5f49024459e6b156b","assignee":{"login":"mrshu","id":461491,"avatar_url":"https://avatars.githubusercontent.com/u/461491?v=3","gravatar_id":"","url":"https://api.github.com/users/mrshu","html_url":"https://github.com/mrshu","followers_url":"https://api.github.com/users/mrshu/followers","following_url":"https://api.github.com/users/mrshu/following{/other_user}","gists_url":"https://api.github.com/users/mrshu/gists{/gist_id}","starred_url":"https://api.github.com/users/mrshu/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mrshu/subscriptions","organizations_url":"https://api.github.com/users/mrshu/orgs","repos_url":"https://api.github.com/users/mrshu/repos","events_url":"https://api.github.com/users/mrshu/events{/privacy}","received_events_url":"https://api.github.com/users/mrshu/received_events","type":"User","site_admin":false},"milestone":null,"commits_url":"https://api.github.com/repos/Foxiy/board2slides/pulls/18/commits","review_comments_url":"https://api.github.com/repos/Foxiy/board2slides/pulls/18/comments","review_comment_url":"https://api.github.com/repos/Foxiy/board2slides/pulls/comments{/number}","comments_url":"https://api.github.com/repos/Foxiy/board2slides/issues/18/comments","statuses_url":"https://api.github.com/repos/Foxiy/board2slides/statuses/bda8cdf8068db9c89fd6062bad605d23a5d84048","head":{"label":"Foxiy:Foxiy/toolkit","ref":"Foxiy/toolkit","sha":"bda8cdf8068db9c89fd6062bad605d23a5d84048","user":{"login":"Foxiy","id":9467741,"avatar_url":"https://avatars.githubusercontent.com/u/9467741?v=3","gravatar_id":"","url":"https://api.github.com/users/Foxiy","html_url":"https://github.com/Foxiy","followers_url":"https://api.github.com/users/Foxiy/followers","following_url":"https://api.github.com/users/Foxiy/following{/other_user}","gists_url":"https://api.github.com/users/Foxiy/gists{/gist_id}","starred_url":"https://api.github.com/users/Foxiy/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Foxiy/subscriptions","organizations_url":"https://api.github.com/users/Foxiy/orgs","repos_url":"https://api.github.com/users/Foxiy/repos","events_url":"https://api.github.com/users/Foxiy/events{/privacy}","received_events_url":"https://api.github.com/users/Foxiy/received_events","type":"User","site_admin":false},"repo":{"id":27374077,"name":"board2slides","full_name":"Foxiy/board2slides","owner":{"login":"Foxiy","id":9467741,"avatar_url":"https://avatars.githubusercontent.com/u/9467741?v=3","gravatar_id":"","url":"https://api.github.com/users/Foxiy","html_url":"https://github.com/Foxiy","followers_url":"https://api.github.com/users/Foxiy/followers","following_url":"https://api.github.com/users/Foxiy/following{/other_user}","gists_url":"https://api.github.com/users/Foxiy/gists{/gist_id}","starred_url":"https://api.github.com/users/Foxiy/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Foxiy/subscriptions","organizations_url":"https://api.github.com/users/Foxiy/orgs","repos_url":"https://api.github.com/users/Foxiy/repos","events_url":"https://api.github.com/users/Foxiy/events{/privacy}","received_events_url":"https://api.github.com/users/Foxiy/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/Foxiy/board2slides","description":"We will turn your video of a board (white or black) to slides (like powerpoint).","fork":false,"url":"https://api.github.com/repos/Foxiy/board2slides","forks_url":"https://api.github.com/repos/Foxiy/board2slides/forks","keys_url":"https://api.github.com/repos/Foxiy/board2slides/keys{/key_id}","collaborators_url":"https://api.github.com/repos/Foxiy/board2slides/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/Foxiy/board2slides/teams","hooks_url":"https://api.github.com/repos/Foxiy/board2slides/hooks","issue_events_url":"https://api.github.com/repos/Foxiy/board2slides/issues/events{/number}","events_url":"https://api.github.com/repos/Foxiy/board2slides/events","assignees_url":"https://api.github.com/repos/Foxiy/board2slides/assignees{/user}","branches_url":"https://api.github.com/repos/Foxiy/board2slides/branches{/branch}","tags_url":"https://api.github.com/repos/Foxiy/board2slides/tags","blobs_url":"https://api.github.com/repos/Foxiy/board2slides/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/Foxiy/board2slides/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/Foxiy/board2slides/git/refs{/sha}","trees_url":"https://api.github.com/repos/Foxiy/board2slides/git/trees{/sha}","statuses_url":"https://api.github.com/repos/Foxiy/board2slides/statuses/{sha}","languages_url":"https://api.github.com/repos/Foxiy/board2slides/languages","stargazers_url":"https://api.github.com/repos/Foxiy/board2slides/stargazers","contributors_url":"https://api.github.com/repos/Foxiy/board2slides/contributors","subscribers_url":"https://api.github.com/repos/Foxiy/board2slides/subscribers","subscription_url":"https://api.github.com/repos/Foxiy/board2slides/subscription","commits_url":"https://api.github.com/repos/Foxiy/board2slides/commits{/sha}","git_commits_url":"https://api.github.com/repos/Foxiy/board2slides/git/commits{/sha}","comments_url":"https://api.github.com/repos/Foxiy/board2slides/comments{/number}","issue_comment_url":"https://api.github.com/repos/Foxiy/board2slides/issues/comments{/number}","contents_url":"https://api.github.com/repos/Foxiy/board2slides/contents/{+path}","compare_url":"https://api.github.com/repos/Foxiy/board2slides/compare/{base}...{head}","merges_url":"https://api.github.com/repos/Foxiy/board2slides/merges","archive_url":"https://api.github.com/repos/Foxiy/board2slides/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/Foxiy/board2slides/downloads","issues_url":"https://api.github.com/repos/Foxiy/board2slides/issues{/number}","pulls_url":"https://api.github.com/repos/Foxiy/board2slides/pulls{/number}","milestones_url":"https://api.github.com/repos/Foxiy/board2slides/milestones{/number}","notifications_url":"https://api.github.com/repos/Foxiy/board2slides/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/Foxiy/board2slides/labels{/name}","releases_url":"https://api.github.com/repos/Foxiy/board2slides/releases{/id}","created_at":"2014-12-01T10:20:35Z","updated_at":"2015-02-04T12:41:54Z","pushed_at":"2015-10-25T22:44:52Z","git_url":"git://github.com/Foxiy/board2slides.git","ssh_url":"git@github.com:Foxiy/board2slides.git","clone_url":"https://github.com/Foxiy/board2slides.git","svn_url":"https://github.com/Foxiy/board2slides","homepage":"","size":20128,"stargazers_count":0,"watchers_count":0,"language":"Python","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":2,"mirror_url":null,"open_issues_count":2,"forks":2,"open_issues":2,"watchers":0,"default_branch":"master"}},"base":{"label":"Foxiy:Foxiy/saving","ref":"Foxiy/saving","sha":"ecf8a56d0cdbdfa340441722eaa659dc365b673c","user":{"login":"Foxiy","id":9467741,"avatar_url":"https://avatars.githubusercontent.com/u/9467741?v=3","gravatar_id":"","url":"https://api.github.com/users/Foxiy","html_url":"https://github.com/Foxiy","followers_url":"https://api.github.com/users/Foxiy/followers","following_url":"https://api.github.com/users/Foxiy/following{/other_user}","gists_url":"https://api.github.com/users/Foxiy/gists{/gist_id}","starred_url":"https://api.github.com/users/Foxiy/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Foxiy/subscriptions","organizations_url":"https://api.github.com/users/Foxiy/orgs","repos_url":"https://api.github.com/users/Foxiy/repos","events_url":"https://api.github.com/users/Foxiy/events{/privacy}","received_events_url":"https://api.github.com/users/Foxiy/received_events","type":"User","site_admin":false},"repo":{"id":27374077,"name":"board2slides","full_name":"Foxiy/board2slides","owner":{"login":"Foxiy","id":9467741,"avatar_url":"https://avatars.githubusercontent.com/u/9467741?v=3","gravatar_id":"","url":"https://api.github.com/users/Foxiy","html_url":"https://github.com/Foxiy","followers_url":"https://api.github.com/users/Foxiy/followers","following_url":"https://api.github.com/users/Foxiy/following{/other_user}","gists_url":"https://api.github.com/users/Foxiy/gists{/gist_id}","starred_url":"https://api.github.com/users/Foxiy/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Foxiy/subscriptions","organizations_url":"https://api.github.com/users/Foxiy/orgs","repos_url":"https://api.github.com/users/Foxiy/repos","events_url":"https://api.github.com/users/Foxiy/events{/privacy}","received_events_url":"https://api.github.com/users/Foxiy/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/Foxiy/board2slides","description":"We will turn your video of a board (white or black) to slides (like powerpoint).","fork":false,"url":"https://api.github.com/repos/Foxiy/board2slides","forks_url":"https://api.github.com/repos/Foxiy/board2slides/forks","keys_url":"https://api.github.com/repos/Foxiy/board2slides/keys{/key_id}","collaborators_url":"https://api.github.com/repos/Foxiy/board2slides/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/Foxiy/board2slides/teams","hooks_url":"https://api.github.com/repos/Foxiy/board2slides/hooks","issue_events_url":"https://api.github.com/repos/Foxiy/board2slides/issues/events{/number}","events_url":"https://api.github.com/repos/Foxiy/board2slides/events","assignees_url":"https://api.github.com/repos/Foxiy/board2slides/assignees{/user}","branches_url":"https://api.github.com/repos/Foxiy/board2slides/branches{/branch}","tags_url":"https://api.github.com/repos/Foxiy/board2slides/tags","blobs_url":"https://api.github.com/repos/Foxiy/board2slides/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/Foxiy/board2slides/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/Foxiy/board2slides/git/refs{/sha}","trees_url":"https://api.github.com/repos/Foxiy/board2slides/git/trees{/sha}","statuses_url":"https://api.github.com/repos/Foxiy/board2slides/statuses/{sha}","languages_url":"https://api.github.com/repos/Foxiy/board2slides/languages","stargazers_url":"https://api.github.com/repos/Foxiy/board2slides/stargazers","contributors_url":"https://api.github.com/repos/Foxiy/board2slides/contributors","subscribers_url":"https://api.github.com/repos/Foxiy/board2slides/subscribers","subscription_url":"https://api.github.com/repos/Foxiy/board2slides/subscription","commits_url":"https://api.github.com/repos/Foxiy/board2slides/commits{/sha}","git_commits_url":"https://api.github.com/repos/Foxiy/board2slides/git/commits{/sha}","comments_url":"https://api.github.com/repos/Foxiy/board2slides/comments{/number}","issue_comment_url":"https://api.github.com/repos/Foxiy/board2slides/issues/comments{/number}","contents_url":"https://api.github.com/repos/Foxiy/board2slides/contents/{+path}","compare_url":"https://api.github.com/repos/Foxiy/board2slides/compare/{base}...{head}","merges_url":"https://api.github.com/repos/Foxiy/board2slides/merges","archive_url":"https://api.github.com/repos/Foxiy/board2slides/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/Foxiy/board2slides/downloads","issues_url":"https://api.github.com/repos/Foxiy/board2slides/issues{/number}","pulls_url":"https://api.github.com/repos/Foxiy/board2slides/pulls{/number}","milestones_url":"https://api.github.com/repos/Foxiy/board2slides/milestones{/number}","notifications_url":"https://api.github.com/repos/Foxiy/board2slides/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/Foxiy/board2slides/labels{/name}","releases_url":"https://api.github.com/repos/Foxiy/board2slides/releases{/id}","created_at":"2014-12-01T10:20:35Z","updated_at":"2015-02-04T12:41:54Z","pushed_at":"2015-10-25T22:44:52Z","git_url":"git://github.com/Foxiy/board2slides.git","ssh_url":"git@github.com:Foxiy/board2slides.git","clone_url":"https://github.com/Foxiy/board2slides.git","svn_url":"https://github.com/Foxiy/board2slides","homepage":"","size":20128,"stargazers_count":0,"watchers_count":0,"language":"Python","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":2,"mirror_url":null,"open_issues_count":2,"forks":2,"open_issues":2,"watchers":0,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/Foxiy/board2slides/pulls/18"},"html":{"href":"https://github.com/Foxiy/board2slides/pull/18"},"issue":{"href":"https://api.github.com/repos/Foxiy/board2slides/issues/18"},"comments":{"href":"https://api.github.com/repos/Foxiy/board2slides/issues/18/comments"},"review_comments":{"href":"https://api.github.com/repos/Foxiy/board2slides/pulls/18/comments"},"review_comment":{"href":"https://api.github.com/repos/Foxiy/board2slides/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/Foxiy/board2slides/pulls/18/commits"},"statuses":{"href":"https://api.github.com/repos/Foxiy/board2slides/statuses/bda8cdf8068db9c89fd6062bad605d23a5d84048"}}}}