{"id":22846534,"url":"https://github.com/jsonkao/opencv-python","last_synced_at":"2025-03-31T05:41:21.982Z","repository":{"id":114471024,"uuid":"76299731","full_name":"jsonkao/opencv-python","owner":"jsonkao","description":"adventures in opencv!","archived":false,"fork":false,"pushed_at":"2016-12-13T00:50:44.000Z","size":5242,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-02-06T10:15:21.415Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/jsonkao.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2016-12-12T22:07:17.000Z","updated_at":"2016-12-12T22:31:48.000Z","dependencies_parsed_at":"2023-06-08T07:15:35.177Z","dependency_job_id":null,"html_url":"https://github.com/jsonkao/opencv-python","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jsonkao%2Fopencv-python","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jsonkao%2Fopencv-python/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jsonkao%2Fopencv-python/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jsonkao%2Fopencv-python/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/jsonkao","download_url":"https://codeload.github.com/jsonkao/opencv-python/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246423494,"owners_count":20774796,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-12-13T03:29:27.340Z","updated_at":"2025-03-31T05:41:21.952Z","avatar_url":"https://github.com/jsonkao.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# opencv-python\nspatiotemporal?\n## 01 Image Loading\n```python\nimg = cv2.imread('file.png', cv2.IMREAD_GRAYSCALE) # reads image in grayscale\ncv2.imshow('myWindow', img) # opens window with image\ncv2.waitKey(0) # waits for any key to be pressed\ncv2.destroyAllWindows()\ncv2.imwrite('newFile.png', img) # writes new img\n```\n\n### 02 Video Loading\n```python\nwebcam = cv2.VideoCapture(0)\n\nwhile True:\n\tret, frame = webcam.read() # we only care about frame\n\tgrayVersion = cv2.cvtColor(frame, cv2.COLOR_BGR2GRAY) # creates object with grayscale of webcam\n\t\n\tcv2.imshow('myColoredWebcam', frame) \n\tcv2.imshow('myGrayscaleWebcam', grayVersion)\n\t\n\tif cv2.waitKey(1) \u0026 0xFF == ord('q'):\n\t\tbreak\n\nwebcam.release()\ncv2.destoryAllWindows()\n```\n\n### 03 Drawing\n```python\nimg = cv2.imread('file.png'), cv2.IMREAD_COLOR) # reads image in color\n\n# line\ncv2.line(img, tuple start point, tuple end point, tuple BGR)\n# rectangle\ncv2.rectangle(img, tuple start point, tuple end point, tuple BGR, int borderWidth) # -1 as border fills in shape\n# circle\ncv2.circle(img, tuple center, int radius, tuple BGR, int borderWidth)\n# polygon\npts = np.array([ [10,10],[20,30],[40,50],[20,20] ], np.int32)\ncv2.polylines(img, [pts], boolean connectEndPointToStartPoint?, tuple BGR, int borderWidth)\n# text\nfont = cv2.FONT_HERSHEY_SIMPLEX\ncv2.putText(img, String text, tuple start point, font, int size, tuple BGR, cv2.LINE_AA)\n```\n\n### 04 IMG OPS\n```python\nimg = cv2.imread(...)\n\nonePixel = img[15,15] # returns array BGR\nimg [15,15] = [255,255,255]\n\n# Region of Image: ROI\nroi = img[100:200,120:220]\nimg[0:50,0:50] = roi # copies all color values over\n\n# adding\nsum = img1 + img2 # adds color values\nweighted = cv2.addWeighted(img1, 0.6, img2, 0.4, 0) # adds color values by weight\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjsonkao%2Fopencv-python","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjsonkao%2Fopencv-python","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjsonkao%2Fopencv-python/lists"}