示例#1
0
文件: hardCam.py 项目: vsimonis/worm1
 def run(self):
     # separate thread
     global done
     while not self.terminated:
         if self.event.wait(1):
             try:
                 self.stream.seek(0)
                 img = Img.open(self.stream)
                 [x, y] = imgProc.getCentroidFromRaw(img)  ##img processing
                 print "x: %d, y: %d" % (x, y)
             finally:
                 self.stream.seek(0)
                 self.stream.truncate()
                 self.event.clear()
                 # Return to pool
                 with lock:
                     pool.append(self)
示例#2
0
文件: valCam.py 项目: vsimonis/worm1
def write_video( stream, img ):
    print ('writing video')
    #stream2 = io.BytesIO()
    with stream.lock:
        #(ksize, kpos) = get_frame(stream)# Find keyframe
        for frame in stream.frames:
            if frame.header: #is keyframe
                stream.seek(frame.position)
                break
         
        # write rest of stream to disk
        with io.open('test1.h264','wb') as output:
            output.write(stream.read())
        
        # process
        #img = Image.open(stream.read1(frame.frame_size)) 
        x, y = imgProc.getCentroidFromRaw(img)
        print "x: %d\ty: %d"%(x,y)
示例#3
0
文件: imgTest.py 项目: vsimonis/worm1
t1 = tic()
J = ipr.threshHist(I1)
print "thresh runtime\t%f" % toc(t1)
io.imshow(J)
plt.show()
t2 = tic()
K = ipr.morphOps(J, 5, 1000)
print "morph runtime\t%f" % toc(t2)

plt.figure()
plt.imshow(K, cmap='gray')
t3 = tic()
x,y = ipr.getCentroid(K)
#plt.scatter(x, y)
print "centroid runtime\t%f" % toc(t3)
#print str(x) + " " + str(y)
plt.show()

t4 = tic()
ipr.getCentroidFromRaw(I1)
print "all runtime\t%f" % toc(t4)

t5 = tic()
ipr.all(I1)
print "all opt\t%f" % toc(t5)

print "\n"