Permalink
Browse files
Some comments and grammar issues tweaks
- Loading branch information...
Showing
with
8 additions
and
7 deletions.
-
+4
−3
Motion/main.py
-
+1
−1
Motion/motion.py
-
+3
−3
Motion/test.py
|
|
@@ -8,16 +8,17 @@ |
|
|
from config import config
|
|
|
import logging
|
|
|
|
|
|
-logging.getLogger("requests").setLevel(logging.WARNING)
|
|
|
+# Send gesture to node server
|
|
|
+logging.getLogger("requests").setLevel(logging.WARNING) # get infos on error
|
|
|
take_photo = False
|
|
|
photo_filepath = ""
|
|
|
-
|
|
|
def SendGesture(gesture):
|
|
|
try:
|
|
|
requests.get("http://localhost:3000/motion/gesture", params=json.dumps(gesture.properties))
|
|
|
except Exception as ex:
|
|
|
print("Could not send gesture: " + str(ex))
|
|
|
|
|
|
+# Received command from node server to take a photo
|
|
|
def ManageCommands(motion):
|
|
|
global take_photo
|
|
|
|
|
|
@@ -28,6 +29,7 @@ def ManageCommands(motion): |
|
|
cv2.imwrite("../public/" + photo_filepath, motion.currentFrame)
|
|
|
take_photo = False
|
|
|
|
|
|
+# Main loop - get gestures and send them
|
|
|
def ManageMotion():
|
|
|
motion = Motion()
|
|
|
|
|
|
@@ -52,7 +54,6 @@ def get(self): |
|
|
filepath = self.get_argument('filepath', 'public/frame.jpg')
|
|
|
take_photo = True
|
|
|
photo_filepath = filepath
|
|
|
- self.write("OK");
|
|
|
|
|
|
if __name__ == '__main__':
|
|
|
threading.Thread(target=ManageMotion).start()
|
|
|
|
|
|
@@ -77,7 +77,7 @@ def GetInformationOnNextFrame(self): |
|
|
return
|
|
|
|
|
|
# Get frame difference to avoid doing things when there is no movement
|
|
|
- self.frameDifference = cv2.absdiff(cv2.cvtColor(Motion.currentFrame, cv2.COLOR_RGB2GRAY), cv2.cvtColor(Motion .previousFrame, cv2.COLOR_BGR2GRAY))
|
|
|
+ self.frameDifference = cv2.absdiff(cv2.cvtColor(Motion.currentFrame, cv2.COLOR_RGB2GRAY), cv2.cvtColor(Motion .previousFrame, cv2.COLOR_RGB2GRAY))
|
|
|
cntGray = 0
|
|
|
for rowGray in self.frameDifference:
|
|
|
for gray in rowGray:
|
|
|
|
|
|
@@ -14,7 +14,7 @@ def nothing(x): |
|
|
def ManageMotion():
|
|
|
motion = Motion()
|
|
|
|
|
|
- # Param on the fly
|
|
|
+ # Params to change on the fly
|
|
|
cv2.namedWindow('paramMinMaxPalm')
|
|
|
cv2.createTrackbar('MAX H', 'paramMinMaxPalm', 1, 255, nothing)
|
|
|
cv2.createTrackbar('MAX S', 'paramMinMaxPalm', 1, 255, nothing)
|
|
|
@@ -51,11 +51,11 @@ def ManageMotion(): |
|
|
if not motion.IsActive():
|
|
|
print("No camera found")
|
|
|
|
|
|
- # Debug Palm Tracking
|
|
|
+ # Debug Palm Tracking (See palm color detection in real time - consuming)
|
|
|
motion.debugPalm = False
|
|
|
|
|
|
while motion.IsActive():
|
|
|
- # Refresh OpenCV
|
|
|
+ # Refresh OpenCV Windows
|
|
|
cv2.waitKey(1)
|
|
|
|
|
|
main.ManageCommands(motion)
|
|
|
|
0 comments on commit
baaea03