IP Updates
@@ -1,10 +1,10 @@
|
||||
import SimpleCV as s
|
||||
import time
|
||||
#cam=s.Camera()
|
||||
cam=s.JpegStreamCamera(r"192.168.173.227:8080/videofeed")
|
||||
cam=s.Camera()
|
||||
#cam=s.JpegStreamCamera(r"192.168.173.227:8080/videofeed")
|
||||
c1=time.clock()
|
||||
while True:
|
||||
img=cam.getImage().show()
|
||||
for a in range(200):
|
||||
img=cam.getImage()#.show()
|
||||
c2=time.clock()
|
||||
print(1/(c1-c2))
|
||||
c1=c2
|
||||
@@ -12,7 +12,7 @@ while count<5:
|
||||
f.draw(width=2)
|
||||
i.show()
|
||||
|
||||
i.flipHorizontal().save(r"E:\Babu\pytry\robocon\face_detect.jpg")
|
||||
i.flipHorizontal().save(r"D:\Babu\github_files\pytry\robocon\face_detect.jpg")
|
||||
##f.show()
|
||||
##import time
|
||||
##cl=time.clock()
|
||||
|
||||
@@ -7,8 +7,10 @@ c1=time.clock()
|
||||
gesture_time=30
|
||||
detection_sleep=False
|
||||
blobs=[None]*gesture_time
|
||||
fname = r"C:\Users\abhas\Desktop\test.avi"
|
||||
vs = s.VideoStream(fps=25,filename=fname,framefill=False)
|
||||
|
||||
debug=True
|
||||
debug=False
|
||||
#d=s.Display()
|
||||
i1=c.getImage()
|
||||
img_width_ori=i1.width
|
||||
@@ -16,8 +18,11 @@ img_height=i1.height
|
||||
i1=i1.crop(img_width_ori/4,0,img_width_ori*3/4,img_height/2).flipHorizontal()
|
||||
img_width=img_width_ori/2
|
||||
count=0
|
||||
print("Recording starts.. :D")
|
||||
while True:
|
||||
i2=c.getImage().crop(img_width_ori/4,0,img_width_ori*3/4,img_height/2).flipHorizontal()
|
||||
i2=c.getImage()
|
||||
vs.writeFrame(i2)
|
||||
i2=i2.crop(img_width_ori/4,0,img_width_ori*3/4,img_height/2).flipHorizontal()
|
||||
i3=(i2-i1)+(i1-i2)
|
||||
i1=i2
|
||||
i3=i3.stretch(10,255).erode(2).dilate(2)
|
||||
@@ -52,10 +57,12 @@ while True:
|
||||
if right_step>left_step:
|
||||
print("Left to right")
|
||||
if not debug:
|
||||
print("Up pressed")
|
||||
press.press_up()
|
||||
else:
|
||||
print("Right to left")
|
||||
if not debug:
|
||||
print("Down pressed")
|
||||
press.press_down()
|
||||
print(c1)
|
||||
detection_sleep=gesture_time*2
|
||||
|
||||
@@ -0,0 +1,5 @@
|
||||
letters=["a","e","c","t","r","s","o"]
|
||||
words=["rate","rose","cat","at","ate","actor","eat","car","roast","star","start","soccer","cast","sore","arc","art","toe","sort"]
|
||||
guess=raw_input()
|
||||
print(guess)
|
||||
|
||||
|
Before Width: | Height: | Size: 67 KiB After Width: | Height: | Size: 56 KiB |
@@ -0,0 +1,66 @@
|
||||
import SimpleCV as s
|
||||
from math import *
|
||||
import time as t
|
||||
thresh=8 # in percentage
|
||||
fname=r"D:\Babu\github_files\pytry\shape_detect\pics\rect.jpg"
|
||||
c=s.Camera()
|
||||
def run():
|
||||
t1=t.clock()
|
||||
i=s.Image(fname).scale(.25)
|
||||
#i=c.getImage()
|
||||
#i.show()
|
||||
blobs=i.findBlobs()
|
||||
|
||||
def isClose(a,b):
|
||||
if float(abs(a-b))/min(a,b)*100<=thresh:
|
||||
return True
|
||||
else:
|
||||
return False
|
||||
|
||||
def checkSymmetry():
|
||||
tmp_img=blob.crop()
|
||||
#tmp_img.show()
|
||||
tmp_img_upper=tmp_img.crop(0,0,tmp_w,tmp_h/2)
|
||||
tmp_img_lower=tmp_img.crop(0,tmp_h/2,tmp_w,tmp_h/2)
|
||||
#tmp_img_upper.sideBySide(tmp_img_lower).show()
|
||||
tmp_blob_upper=tmp_img_upper.findBlobs()[0]
|
||||
tmp_blob_lower=tmp_img_lower.findBlobs()[0]
|
||||
return isClose(tmp_blob_upper.area(),tmp_blob_lower.area())
|
||||
|
||||
def checkCircle():
|
||||
if isClose(tmp_w,tmp_h) and isClose(pi*(tmp_w/2)**2,tmp_a):
|
||||
return "Circle"
|
||||
else:
|
||||
return False
|
||||
|
||||
def checkRect():
|
||||
if isClose(tmp_w*tmp_h,tmp_a):
|
||||
return "Rectangle"
|
||||
else:
|
||||
return False
|
||||
|
||||
def checkTri():
|
||||
if isClose(0.5*tmp_w*tmp_h,tmp_a) and not checkSymmetry():
|
||||
return "Triangle"
|
||||
else:
|
||||
return False
|
||||
|
||||
if blobs:
|
||||
#blobs.show()
|
||||
for blob in blobs:
|
||||
tmp_w=blob.width()
|
||||
tmp_h=blob.height()
|
||||
tmp_a=blob.area()
|
||||
#print(tmp_w,tmp_h,tmp_a)
|
||||
isCircle=checkCircle()
|
||||
#print(isCircle)
|
||||
isRect=checkRect()
|
||||
#print(isRect)
|
||||
isTri=checkTri()
|
||||
#print(isTri)
|
||||
print isCircle or isRect or isTri
|
||||
|
||||
t2=t.clock()
|
||||
print(1/(t2-t1))
|
||||
|
||||
run()
|
||||
|
After Width: | Height: | Size: 8.4 KiB |
|
After Width: | Height: | Size: 2.5 KiB |
|
Before Width: | Height: | Size: 10 KiB After Width: | Height: | Size: 11 KiB |
|
Before Width: | Height: | Size: 11 KiB After Width: | Height: | Size: 11 KiB |
|
Before Width: | Height: | Size: 7.4 KiB After Width: | Height: | Size: 7.7 KiB |
|
Before Width: | Height: | Size: 11 KiB After Width: | Height: | Size: 12 KiB |
|
Before Width: | Height: | Size: 9.8 KiB After Width: | Height: | Size: 10 KiB |
|
Before Width: | Height: | Size: 10 KiB After Width: | Height: | Size: 11 KiB |