{"id":18914764,"url":"https://github.com/lau1944/colorblue_control_object","last_synced_at":"2026-04-29T10:34:31.840Z","repository":{"id":134023054,"uuid":"230747498","full_name":"lau1944/ColorBlue_Control_Object","owner":"lau1944","description":"Using OpenCV2 detects blue color , control images position on screen (put the right color in the box !)","archived":false,"fork":false,"pushed_at":"2019-12-31T04:24:29.000Z","size":923,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-05-24T18:41:51.072Z","etag":null,"topics":["opencv","python"],"latest_commit_sha":null,"homepage":"","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/lau1944.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":"2019-12-29T12:31:31.000Z","updated_at":"2019-12-31T04:24:31.000Z","dependencies_parsed_at":null,"dependency_job_id":"525ad6ea-5a74-4a2c-a366-5d35e1360ab9","html_url":"https://github.com/lau1944/ColorBlue_Control_Object","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/lau1944/ColorBlue_Control_Object","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lau1944%2FColorBlue_Control_Object","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lau1944%2FColorBlue_Control_Object/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lau1944%2FColorBlue_Control_Object/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lau1944%2FColorBlue_Control_Object/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/lau1944","download_url":"https://codeload.github.com/lau1944/ColorBlue_Control_Object/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lau1944%2FColorBlue_Control_Object/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":32422044,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-29T06:29:02.080Z","status":"ssl_error","status_checked_at":"2026-04-29T06:29:00.631Z","response_time":110,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"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":["opencv","python"],"created_at":"2024-11-08T10:12:45.647Z","updated_at":"2026-04-29T10:34:31.824Z","avatar_url":"https://github.com/lau1944.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# ColorBlue_Control_Object\nUsing OpenCV2 detects blue color , control images position on screen (put the right color in the box !)\n\n利用颜色控制窗口内目标图片\n### A Game Using OpenCV2 To Control Images\n\nAfter detect color blue, a red point will display on the center of the color blue\n\nMove the red point to the images **slowly** and control the images !\n\n使用时将蓝色中心区域的红点对准图片，缓慢移动图片\n\nDemo:\n\u003cp align=\"center\"\u003e\n  \u003cimg  src=\"https://github.com/lau1944/ColorBlue_Control_Object/blob/master/Untitled.png\"  width=\"600\"/\u003e\n\u003c/p\u003e\n\n\u003cp align=\"center\"\u003e\n  \u003cimg  src=\"https://github.com/lau1944/ColorBlue_Control_Object/blob/master/Untitled1.png\"  width=\"600\"/\u003e\n\u003c/p\u003e\n\n\n### Code Explain \n- **Step 1** .Display Images and Rectangle box\n\n Randomly produce imageY in three places (50, 250 , 450)\n```python\n#generate random position for those three colors\nblue_dis = random.randrange (50,450,200)\nif blue_dis == 450:\n    yellow_dis = random.randrange(50,250,200)\n    if yellow_dis == 50:\n        green_dis = 250\n    if yellow_dis == 250:\n        green_dis = 50   \nelif blue_dis == 50:\n    yellow_dis = random.randrange(250,450,200)\n    if yellow_dis == 250:\n        green_dis = 450\n    if yellow_dis == 450:\n        green_dis = 250   \nelif blue_dis == 250:\n    yellow_dis = random.randrange(50,450,400)\n    if yellow_dis == 50:\n        green_dis = 450\n    if yellow_dis == 450:\n        green_dis = 50   \n```\n\n display images and rectangle box\n```python\n    #insert logo function with random position\n    InsertLogo_2(frame,blue_img,yBluelogo,blue_dis)\n    InsertLogo_2(frame,green_img,yGreenlogo,green_dis)\n    InsertLogo_2(frame,yellow_img,yYellowlogo,yellow_dis)\n    \n    # yellow box\n    cv2.rectangle(frame, (50,350), (150, 450),(255,255,0), 3)\n    # blue box\n    cv2.rectangle(frame, (200,350), (300, 450),(30,144,255), 3)\n    # green box\n    cv2.rectangle(frame, (400,350), (500, 450),(124,252,0), 3)\n```\n\n\n- **Step 2** .Detect Blue Color\n```python\n  #find blue in webcam\n    centerBlue = None\n    cnts = cv2.findContours(mask.copy(), cv2.RETR_EXTERNAL, cv2.CHAIN_APPROX_SIMPLE)[-2]\n    if len(cnts) \u003e 0:\n\t    c = max(cnts, key=cv2.contourArea)\n\t    ((xBlue, yBlue), radius) = cv2.minEnclosingCircle(c)\n\t    M = cv2.moments(c)\n      # center blue location\n\t    xBlue=int(M[\"m10\"] / M[\"m00\"])\n\t    yBlue=int(M[\"m01\"] / M[\"m00\"])\n\t    centerBlue = (int(M[\"m10\"] / M[\"m00\"]), int(M[\"m01\"] / M[\"m00\"]))\n\t    if radius \u003e 10:\n\t\t    mode = False\n\t\t    cv2.circle(frame, centerBlue, 5, (0, 0, 255), -1)  \n```\n\n- **Step 3** .Control the images\n```python\n#controller !!\n    if xBlue \u003e= blue_dis and xBlue \u003c= blue_dis + 100 :\n        if yBlue \u003e= yBluelogo and yBlue \u003c= yBluelogo+100 :\n            yBluelogo = yBlue\n            # xBlue is the central of blue part\n            # -50 in order to let imageX display on the red point\n            blue_dis = xBlue-50\n    if xBlue \u003e= yellow_dis and xBlue \u003c= yellow_dis + 100 :\n        if yBlue \u003e= yYellowlogo and yBlue \u003c= yYellowlogo+100 :\n            yYellowlogo = yBlue\n            yellow_dis = xBlue-50\n    if xBlue \u003e= green_dis and xBlue \u003c= green_dis + 100 :\n        if yBlue \u003e= yGreenlogo and yBlue \u003c= yGreenlogo+100 :\n            yGreenlogo = yBlue\n            green_dis = xBlue-50       \n```\n\n\n## Thank You !\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flau1944%2Fcolorblue_control_object","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Flau1944%2Fcolorblue_control_object","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flau1944%2Fcolorblue_control_object/lists"}