mirror of
https://github.com/OSURoboticsClub/Rover_2017_2018.git
synced 2025-11-08 10:11:14 +00:00
sample code stuff for goal tracking, ball_tracking.py uses a webcam and detects green. Currently testing hardware vs software issues on my surface since distance is a huge issue for testing currently
This commit is contained in:
12
software/rover/gate_navigation/.idea/gate_navigation.iml
generated
Normal file
12
software/rover/gate_navigation/.idea/gate_navigation.iml
generated
Normal file
@@ -0,0 +1,12 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<module type="PYTHON_MODULE" version="4">
|
||||
<component name="NewModuleRootManager">
|
||||
<content url="file://$MODULE_DIR$" />
|
||||
<orderEntry type="inheritedJdk" />
|
||||
<orderEntry type="sourceFolder" forTests="false" />
|
||||
</component>
|
||||
<component name="TestRunnerService">
|
||||
<option name="projectConfiguration" value="Nosetests" />
|
||||
<option name="PROJECT_TEST_RUNNER" value="Nosetests" />
|
||||
</component>
|
||||
</module>
|
||||
4
software/rover/gate_navigation/.idea/misc.xml
generated
Normal file
4
software/rover/gate_navigation/.idea/misc.xml
generated
Normal file
@@ -0,0 +1,4 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="ProjectRootManager" version="2" project-jdk-name="Python 2.7" project-jdk-type="Python SDK" />
|
||||
</project>
|
||||
8
software/rover/gate_navigation/.idea/modules.xml
generated
Normal file
8
software/rover/gate_navigation/.idea/modules.xml
generated
Normal file
@@ -0,0 +1,8 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="ProjectModuleManager">
|
||||
<modules>
|
||||
<module fileurl="file://$PROJECT_DIR$/.idea/gate_navigation.iml" filepath="$PROJECT_DIR$/.idea/gate_navigation.iml" />
|
||||
</modules>
|
||||
</component>
|
||||
</project>
|
||||
7
software/rover/gate_navigation/.idea/other.xml
generated
Normal file
7
software/rover/gate_navigation/.idea/other.xml
generated
Normal file
@@ -0,0 +1,7 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="PySciProjectComponent">
|
||||
<option name="PY_SCI_VIEW" value="true" />
|
||||
<option name="PY_SCI_VIEW_SUGGESTED" value="true" />
|
||||
</component>
|
||||
</project>
|
||||
227
software/rover/gate_navigation/.idea/workspace.xml
generated
Normal file
227
software/rover/gate_navigation/.idea/workspace.xml
generated
Normal file
@@ -0,0 +1,227 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="ChangeListManager">
|
||||
<list default="true" id="8cd739a2-89e1-4550-a6c9-9dc40381110e" name="Default" comment="" />
|
||||
<option name="EXCLUDED_CONVERTED_TO_IGNORED" value="true" />
|
||||
<option name="TRACKING_ENABLED" value="true" />
|
||||
<option name="SHOW_DIALOG" value="false" />
|
||||
<option name="HIGHLIGHT_CONFLICTS" value="true" />
|
||||
<option name="HIGHLIGHT_NON_ACTIVE_CHANGELIST" value="false" />
|
||||
<option name="LAST_RESOLUTION" value="IGNORE" />
|
||||
</component>
|
||||
<component name="FileEditorManager">
|
||||
<leaf>
|
||||
<file leaf-file-name="gate_navi.py" pinned="false" current-in-tab="false">
|
||||
<entry file="file://$PROJECT_DIR$/gate_navi.py">
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state relative-caret-position="306">
|
||||
<caret line="22" column="5" lean-forward="true" selection-start-line="22" selection-start-column="5" selection-end-line="22" selection-end-column="5" />
|
||||
<folding>
|
||||
<element signature="e#0#10#0" expanded="true" />
|
||||
</folding>
|
||||
</state>
|
||||
</provider>
|
||||
</entry>
|
||||
</file>
|
||||
<file leaf-file-name="ball_tracking.py" pinned="false" current-in-tab="true">
|
||||
<entry file="file://$PROJECT_DIR$/ball_tracking.py">
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state relative-caret-position="234">
|
||||
<caret line="20" column="26" lean-forward="true" selection-start-line="20" selection-start-column="26" selection-end-line="20" selection-end-column="26" />
|
||||
<folding>
|
||||
<element signature="e#127#156#0" expanded="true" />
|
||||
</folding>
|
||||
</state>
|
||||
</provider>
|
||||
</entry>
|
||||
</file>
|
||||
</leaf>
|
||||
</component>
|
||||
<component name="IdeDocumentHistory">
|
||||
<option name="CHANGED_PATHS">
|
||||
<list>
|
||||
<option value="$PROJECT_DIR$/gate_navi.py" />
|
||||
<option value="$PROJECT_DIR$/ball_tracking.py" />
|
||||
</list>
|
||||
</option>
|
||||
</component>
|
||||
<component name="JsBuildToolGruntFileManager" detection-done="true" sorting="DEFINITION_ORDER" />
|
||||
<component name="JsBuildToolPackageJson" detection-done="true" sorting="DEFINITION_ORDER" />
|
||||
<component name="JsGulpfileManager">
|
||||
<detection-done>true</detection-done>
|
||||
<sorting>DEFINITION_ORDER</sorting>
|
||||
</component>
|
||||
<component name="ProjectFrameBounds">
|
||||
<option name="x" value="1063" />
|
||||
<option name="y" value="534" />
|
||||
<option name="width" value="1650" />
|
||||
<option name="height" value="1043" />
|
||||
</component>
|
||||
<component name="ProjectView">
|
||||
<navigator currentView="ProjectPane" proportions="" version="1">
|
||||
<flattenPackages />
|
||||
<showMembers />
|
||||
<showModules />
|
||||
<showLibraryContents />
|
||||
<hideEmptyPackages />
|
||||
<abbreviatePackageNames />
|
||||
<autoscrollToSource />
|
||||
<autoscrollFromSource />
|
||||
<sortByType />
|
||||
<manualOrder />
|
||||
<foldersAlwaysOnTop value="true" />
|
||||
</navigator>
|
||||
<panes>
|
||||
<pane id="Scratches" />
|
||||
<pane id="ProjectPane">
|
||||
<subPane>
|
||||
<expand>
|
||||
<path>
|
||||
<item name="gate_navigation" type="b2602c69:ProjectViewProjectNode" />
|
||||
<item name="gate_navigation" type="462c0819:PsiDirectoryNode" />
|
||||
</path>
|
||||
</expand>
|
||||
<select />
|
||||
</subPane>
|
||||
</pane>
|
||||
<pane id="Scope" />
|
||||
</panes>
|
||||
</component>
|
||||
<component name="PropertiesComponent">
|
||||
<property name="nodejs_interpreter_path.stuck_in_default_project" value="undefined stuck path" />
|
||||
<property name="WebServerToolWindowFactoryState" value="false" />
|
||||
<property name="last_opened_file_path" value="$PROJECT_DIR$" />
|
||||
</component>
|
||||
<component name="RunDashboard">
|
||||
<option name="ruleStates">
|
||||
<list>
|
||||
<RuleState>
|
||||
<option name="name" value="ConfigurationTypeDashboardGroupingRule" />
|
||||
</RuleState>
|
||||
<RuleState>
|
||||
<option name="name" value="StatusDashboardGroupingRule" />
|
||||
</RuleState>
|
||||
</list>
|
||||
</option>
|
||||
</component>
|
||||
<component name="RunManager">
|
||||
<configuration default="true" type="PythonConfigurationType" factoryName="Python">
|
||||
<option name="INTERPRETER_OPTIONS" value="" />
|
||||
<option name="PARENT_ENVS" value="true" />
|
||||
<envs>
|
||||
<env name="PYTHONUNBUFFERED" value="1" />
|
||||
</envs>
|
||||
<option name="SDK_HOME" value="" />
|
||||
<option name="WORKING_DIRECTORY" value="" />
|
||||
<option name="IS_MODULE_SDK" value="false" />
|
||||
<option name="ADD_CONTENT_ROOTS" value="true" />
|
||||
<option name="ADD_SOURCE_ROOTS" value="true" />
|
||||
<module name="gate_navigation" />
|
||||
<EXTENSION ID="PythonCoverageRunConfigurationExtension" enabled="false" sample_coverage="true" runner="coverage.py" />
|
||||
<option name="SCRIPT_NAME" value="" />
|
||||
<option name="PARAMETERS" value="" />
|
||||
<option name="SHOW_COMMAND_LINE" value="true" />
|
||||
<option name="EMULATE_TERMINAL" value="false" />
|
||||
<option name="MODULE_MODE" value="false" />
|
||||
</configuration>
|
||||
<configuration name="ball_tracking" type="PythonConfigurationType" factoryName="Python" temporary="true">
|
||||
<option name="INTERPRETER_OPTIONS" value="" />
|
||||
<option name="PARENT_ENVS" value="true" />
|
||||
<envs>
|
||||
<env name="PYTHONUNBUFFERED" value="1" />
|
||||
</envs>
|
||||
<option name="SDK_HOME" value="" />
|
||||
<option name="WORKING_DIRECTORY" value="$PROJECT_DIR$" />
|
||||
<option name="IS_MODULE_SDK" value="true" />
|
||||
<option name="ADD_CONTENT_ROOTS" value="true" />
|
||||
<option name="ADD_SOURCE_ROOTS" value="true" />
|
||||
<module name="gate_navigation" />
|
||||
<EXTENSION ID="PythonCoverageRunConfigurationExtension" enabled="false" sample_coverage="true" runner="coverage.py" />
|
||||
<option name="SCRIPT_NAME" value="$PROJECT_DIR$/ball_tracking.py" />
|
||||
<option name="PARAMETERS" value="" />
|
||||
<option name="SHOW_COMMAND_LINE" value="true" />
|
||||
<option name="EMULATE_TERMINAL" value="false" />
|
||||
<option name="MODULE_MODE" value="false" />
|
||||
</configuration>
|
||||
<recent_temporary>
|
||||
<list size="1">
|
||||
<item index="0" class="java.lang.String" itemvalue="Python.ball_tracking" />
|
||||
</list>
|
||||
</recent_temporary>
|
||||
</component>
|
||||
<component name="ShelveChangesManager" show_recycled="false">
|
||||
<option name="remove_strategy" value="false" />
|
||||
</component>
|
||||
<component name="SvnConfiguration">
|
||||
<configuration />
|
||||
</component>
|
||||
<component name="TaskManager">
|
||||
<task active="true" id="Default" summary="Default task">
|
||||
<changelist id="8cd739a2-89e1-4550-a6c9-9dc40381110e" name="Default" comment="" />
|
||||
<created>1517696081852</created>
|
||||
<option name="number" value="Default" />
|
||||
<option name="presentableId" value="Default" />
|
||||
<updated>1517696081852</updated>
|
||||
</task>
|
||||
<servers />
|
||||
</component>
|
||||
<component name="ToolWindowManager">
|
||||
<frame x="1063" y="534" width="1650" height="1043" extended-state="0" />
|
||||
<editor active="true" />
|
||||
<layout>
|
||||
<window_info id="TODO" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="6" side_tool="false" content_ui="tabs" />
|
||||
<window_info id="Event Log" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="true" show_stripe_button="true" weight="0.0" sideWeight="0.502442" order="-1" side_tool="true" content_ui="tabs" />
|
||||
<window_info id="Documentation" active="false" anchor="right" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="true" show_stripe_button="true" weight="0.0" sideWeight="0.5" order="-1" side_tool="false" content_ui="tabs" x="0" y="0" width="362" height="843" />
|
||||
<window_info id="Version Control" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="false" weight="0.33" sideWeight="0.5" order="-1" side_tool="false" content_ui="tabs" />
|
||||
<window_info id="Python Console" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="true" show_stripe_button="true" weight="0.0" sideWeight="0.497558" order="-1" side_tool="false" content_ui="tabs" />
|
||||
<window_info id="Run" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="2" side_tool="false" content_ui="tabs" />
|
||||
<window_info id="Terminal" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="-1" side_tool="false" content_ui="tabs" />
|
||||
<window_info id="Project" active="false" anchor="left" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="true" show_stripe_button="true" weight="0.24969475" sideWeight="0.5" order="0" side_tool="false" content_ui="combo" />
|
||||
<window_info id="Docker" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="false" weight="0.33" sideWeight="0.5" order="-1" side_tool="false" content_ui="tabs" />
|
||||
<window_info id="Database" active="false" anchor="right" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="-1" side_tool="false" content_ui="tabs" />
|
||||
<window_info id="SciView" active="false" anchor="right" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="-1" side_tool="false" content_ui="tabs" />
|
||||
<window_info id="Structure" active="false" anchor="left" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.25" sideWeight="0.5" order="1" side_tool="false" content_ui="tabs" />
|
||||
<window_info id="Favorites" active="false" anchor="left" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="-1" side_tool="true" content_ui="tabs" />
|
||||
<window_info id="Debug" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.4" sideWeight="0.5" order="3" side_tool="false" content_ui="tabs" />
|
||||
<window_info id="Cvs" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.25" sideWeight="0.5" order="4" side_tool="false" content_ui="tabs" />
|
||||
<window_info id="Hierarchy" active="false" anchor="right" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.25" sideWeight="0.5" order="2" side_tool="false" content_ui="combo" />
|
||||
<window_info id="Message" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="0" side_tool="false" content_ui="tabs" />
|
||||
<window_info id="Commander" active="false" anchor="right" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.4" sideWeight="0.5" order="0" side_tool="false" content_ui="tabs" />
|
||||
<window_info id="Find" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="1" side_tool="false" content_ui="tabs" />
|
||||
<window_info id="Inspection" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.4" sideWeight="0.5" order="5" side_tool="false" content_ui="tabs" />
|
||||
<window_info id="Ant Build" active="false" anchor="right" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.25" sideWeight="0.5" order="1" side_tool="false" content_ui="tabs" />
|
||||
</layout>
|
||||
</component>
|
||||
<component name="TypeScriptGeneratedFilesManager">
|
||||
<option name="version" value="1" />
|
||||
</component>
|
||||
<component name="VcsContentAnnotationSettings">
|
||||
<option name="myLimit" value="2678400000" />
|
||||
</component>
|
||||
<component name="XDebuggerManager">
|
||||
<breakpoint-manager />
|
||||
<watches-manager />
|
||||
</component>
|
||||
<component name="editorHistoryManager">
|
||||
<entry file="file://$PROJECT_DIR$/gate_navi.py">
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state relative-caret-position="306">
|
||||
<caret line="22" column="5" lean-forward="true" selection-start-line="22" selection-start-column="5" selection-end-line="22" selection-end-column="5" />
|
||||
<folding>
|
||||
<element signature="e#0#10#0" expanded="true" />
|
||||
</folding>
|
||||
</state>
|
||||
</provider>
|
||||
</entry>
|
||||
<entry file="file://$PROJECT_DIR$/ball_tracking.py">
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state relative-caret-position="234">
|
||||
<caret line="20" column="26" lean-forward="true" selection-start-line="20" selection-start-column="26" selection-end-line="20" selection-end-column="26" />
|
||||
<folding>
|
||||
<element signature="e#127#156#0" expanded="true" />
|
||||
</folding>
|
||||
</state>
|
||||
</provider>
|
||||
</entry>
|
||||
</component>
|
||||
</project>
|
||||
104
software/rover/gate_navigation/ball_tracking.py
Normal file
104
software/rover/gate_navigation/ball_tracking.py
Normal file
@@ -0,0 +1,104 @@
|
||||
# USAGE
|
||||
# python ball_tracking.py --video ball_tracking_example.mp4
|
||||
# python ball_tracking.py
|
||||
|
||||
# import the necessary packages
|
||||
from collections import deque
|
||||
import numpy as np
|
||||
import argparse
|
||||
import imutils
|
||||
import cv2
|
||||
|
||||
# construct the argument parse and parse the arguments
|
||||
ap = argparse.ArgumentParser()
|
||||
ap.add_argument("-v", "--video", help="path to the (optional) video file")
|
||||
ap.add_argument("-b", "--buffer", type=int, default=64, help="max buffer size")
|
||||
args = vars(ap.parse_args())
|
||||
|
||||
# define the lower and upper boundaries of the "green"
|
||||
# ball in the HSV color space, then initialize the
|
||||
# list of tracked points
|
||||
greenLower = (50, 112, 50)
|
||||
greenUpper = (144, 255, 145)
|
||||
pts = deque(maxlen=args["buffer"])
|
||||
|
||||
# if a video path was not supplied, grab the reference
|
||||
# to the webcam
|
||||
if not args.get("video", False):
|
||||
camera = cv2.VideoCapture(1)
|
||||
|
||||
# otherwise, grab a reference to the video file
|
||||
else:
|
||||
camera = cv2.VideoCapture(args["video"])
|
||||
|
||||
# keep looping
|
||||
while True:
|
||||
# grab the current frame
|
||||
(grabbed, frame) = camera.read()
|
||||
|
||||
# if we are viewing a video and we did not grab a frame,
|
||||
# then we have reached the end of the video
|
||||
if args.get("video") and not grabbed:
|
||||
break
|
||||
|
||||
# resize the frame, blur it, and convert it to the HSV
|
||||
# color space
|
||||
frame = imutils.resize(frame, width=1000)
|
||||
# blurred = cv2.GaussianBlur(frame, (11, 11), 0)
|
||||
hsv = cv2.cvtColor(frame, cv2.COLOR_BGR2HSV)
|
||||
|
||||
# construct a mask for the color "green", then perform
|
||||
# a series of dilations and erosions to remove any small
|
||||
# blobs left in the mask
|
||||
mask = cv2.inRange(hsv, greenLower, greenUpper)
|
||||
mask = cv2.erode(mask, None, iterations=2)
|
||||
mask = cv2.dilate(mask, None, iterations=2)
|
||||
|
||||
# find contours in the mask and initialize the current
|
||||
# (x, y) center of the ball
|
||||
cnts = cv2.findContours(mask.copy(), cv2.RETR_EXTERNAL, cv2.CHAIN_APPROX_SIMPLE)[-2]
|
||||
center = None
|
||||
|
||||
# only proceed if at least one contour was found
|
||||
if len(cnts) > 0:
|
||||
# find the largest contour in the mask, then use
|
||||
# it to compute the minimum enclosing circle and
|
||||
# centroid
|
||||
c = max(cnts, key=cv2.contourArea)
|
||||
((x, y), radius) = cv2.minEnclosingCircle(c)
|
||||
M = cv2.moments(c)
|
||||
center = (int(M["m10"] / M["m00"]), int(M["m01"] / M["m00"]))
|
||||
|
||||
# only proceed if the radius meets a minimum size
|
||||
if radius > 1:
|
||||
# draw the circle and centroid on the frame,
|
||||
# then update the list of tracked points
|
||||
cv2.circle(frame, (int(x), int(y)), int(radius), (0, 255, 255), 2)
|
||||
cv2.circle(frame, center, 5, (0, 0, 255), -1)
|
||||
|
||||
# update the points queue
|
||||
pts.appendleft(center)
|
||||
|
||||
# loop over the set of tracked points
|
||||
for i in xrange(1, len(pts)):
|
||||
# if either of the tracked points are None, ignore
|
||||
# them
|
||||
if pts[i - 1] is None or pts[i] is None:
|
||||
continue
|
||||
|
||||
# otherwise, compute the thickness of the line and
|
||||
# draw the connecting lines
|
||||
thickness = int(np.sqrt(args["buffer"] / float(i + 1)) * 2.5)
|
||||
cv2.line(frame, pts[i - 1], pts[i], (0, 0, 255), thickness)
|
||||
|
||||
# show the frame to our screen
|
||||
cv2.imshow("Frame", frame)
|
||||
key = cv2.waitKey(1) & 0xFF
|
||||
|
||||
# if the 'q' key is pressed, stop the loop
|
||||
if key == ord("q"):
|
||||
break
|
||||
|
||||
# cleanup the camera and close any open windows
|
||||
camera.release()
|
||||
cv2.destroyAllWindows()
|
||||
BIN
software/rover/gate_navigation/ball_tracking_example.mp4
Normal file
BIN
software/rover/gate_navigation/ball_tracking_example.mp4
Normal file
Binary file not shown.
42
software/rover/gate_navigation/gate_navi.py
Normal file
42
software/rover/gate_navigation/gate_navi.py
Normal file
@@ -0,0 +1,42 @@
|
||||
import cv2
|
||||
import numpy as np
|
||||
import sys
|
||||
|
||||
def main():
|
||||
# Webcam number 0 is used to capture the frames
|
||||
# camera = cv2.VideoCapture(0)
|
||||
|
||||
# construct the argument parse and parse the arguments
|
||||
# ap = argparse.ArgumentParser()
|
||||
# ap.add_argument("-i", "--image", help="path to the image")
|
||||
# args = vars(ap.parse_args())
|
||||
|
||||
# load the image
|
||||
image = cv2.imread("pokemon_games.png")
|
||||
|
||||
# define the list of boundaries
|
||||
boundaries = [
|
||||
([17, 15, 100], [50, 56, 200]),
|
||||
([86, 31, 4], [220, 88, 50]),
|
||||
([25, 146, 190], [62, 174, 250]),
|
||||
([103, 86, 65], [165, 163, 168])
|
||||
]
|
||||
|
||||
# loop over the boundaries
|
||||
for (lower, upper) in boundaries:
|
||||
# create NumPy arrays from the boundaries
|
||||
lower = np.array(lower, dtype="uint8")
|
||||
upper = np.array(upper, dtype="uint8")
|
||||
|
||||
# find the colors within the specified boundaries and apply
|
||||
# the mask
|
||||
mask = cv2.inRange(image, lower, upper)
|
||||
output = cv2.bitwise_and(image, image, mask=mask)
|
||||
|
||||
# show the images
|
||||
cv2.imshow("images", np.hstack([image, output]))
|
||||
cv2.waitKey(0)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
BIN
software/rover/gate_navigation/pokemon_games.png
Normal file
BIN
software/rover/gate_navigation/pokemon_games.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 601 KiB |
Reference in New Issue
Block a user