Exemple #1
0
 def fetchImage(self, location):
     dataa = self.server.getImage()
     if dataa == "FAILED":
         return
     with open(location, "wb") as handle:
         handle.write(dataa.data)
     self.gui.debugPrint(str(sd.detectShapes(location)))
 def test(self):
     output = sh.detectShapes("/home/lars/Pictures/Demo/Works1.jpg")
     print output
     matrix = m.Matrix2(output[0], output[1])
     posAndCorner = matrix.updatePositionAndOrientations(output[2], output[3])
     print posAndCorner
     print str((posAndCorner[1] * 180) / math.pi)
Exemple #3
0
 def testFindCoordinates(self):
     shapeDetection = shapeDet.detectShapes("/home/lars/Pictures/Demo/FUCKOFFS/fuckoff20.jpg")
     print shapeDetection
     
     matrix = Matrix2(864, 648, "grid.csv")
     output = matrix.updatePosAndAngle(shapeDetection[2], shapeDetection[3])
     print output
     print "in graden " + str(output[3])
Exemple #4
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"
Exemple #5
0
from positioning.photoanalysis import PhotoAnalysis
import randapparatuur.shapeDetection as sd
import positioning.grid as grid


cvresult = sd.detectShapes("fuckoff5.jpg")
grid = grid.CSVToGrid("../positioning/grid.csv")
print "cvresult: " + str(cvresult)

fl = zip(cvresult[2], cvresult[3])
print "1"
pA1 = PhotoAnalysis(fl, grid, (400, 300))
print pA1.location
print ""
print "2"
pA2 = PhotoAnalysis(fl[1:] + fl[:1], grid, (400, 300))
print pA2.location
print ""
print "3"
pA3 = PhotoAnalysis(fl[2:] + fl[:2], grid, (400, 300))
print pA3.location
print ""
print "4"
pA4 = PhotoAnalysis(fl[3:] + fl[:3], grid, (400, 300))
print pA4.location

print pA1.locationCm, pA1.angle, pA1.triangleSideInPixels()
print pA2.locationCm, pA2.angle, pA2.triangleSideInPixels()
print pA3.locationCm, pA3.angle, pA3.triangleSideInPixels()
print pA4.locationCm, pA4.angle, pA4.triangleSideInPixels()
Exemple #6
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)