Ejemplo n.º 1
0
 def updateInformation(self):
     def updateInformationMQ():
         if self.location != None:
             mq.sendLocation(self.location[0],self.location[1])
         if self.realHeight != None:
             mq.sendHeight(int(self.realHeight)*10)#in mm
         if self.angle != None:
             mq.sendAngle(int(self.angle))
         if cvresult != None:
             mq.sendCvResults(cvresult)
     
     print "updating info"
     cam.makePhoto("/dev/shm/autopic.jpg")
     cvresult = sd.detectShapes("/dev/shm/autopic.jpg")
     print "CvResult " + str(cvresult)
     pA = PhotoAnalysis(zip(cvresult[2], cvresult[3]), grid, (864, 648))
     
     if pA.locationCm != None and pA.angle != None:
         self.setLocation(pA.locationCm, pA.angle)
         print "Location " + str(self.location)
         print "Angle " + str(self.angle)
         print "GoalLocation " + str(self.goalLocation)
         print "Height " + str(self.realHeight)
         updateInformationMQ()
         
         if self.goalLocation != None and nearGoal(self.location, self.goalLocation):
             print "NEAR THE GOAL"
             self.moving = False
             if self.goalTablet != None:
                 #zeg tegen iPad: "Ik ben er"
                 askTablet(self.goalTablet)
                 time.sleep(1)
                 
                 #PROBEER DRIE KEER
                 for i in range(3):
                     #trek een foto en lees de QR code
                     decodedQR = cam.makePhotoAndDecodeQRCode("iPad"+str(i)+".jpg")
                     time.sleep(0.23)
                     if not decodedQR:
                         continue #QR code kon niet gedecodeerd worden
                     #zet nieuw goal
                     self.parseQRCommand(decrypt(decodedQR))
                     break
             else:
                 #DOEN WAT GE MOET DOEN BIJ AANKOMEN OP LOCATIE.
                 self.pid.setPoint(0)
                 self.heightCorrectionFlag = False
                 self.stopAllMotors()
     else:
         print "No Location found"
Ejemplo n.º 2
0
 def getImage(self):
     jpg = "automaticPhoto.jpg"
     cam.makePhoto(jpg)
     with open(jpg, "rb") as handle:
         return xmlrpclib.Binary(handle.read())
Ejemplo n.º 3
0
import time
import randapparatuur.camera as cam
import randapparatuur.shapeDetection as sd

starttime = time.time()
cam.makePhoto("autopic.jpg")
camtime = time.time()
camelapsed = camtime - starttime
cvresult = sd.detectShapes("autopic.jpg")
elapsed = time.time()-camtime
total = time.time()-starttime
print "cvresult: " + str(cvresult)
print "cam time elapsed: " + str(camelapsed)
print "cv time elapsed: " + str(elapsed)
print "total time elapsed: " + str(total)