Beispiel #1
0
 def runSearchCamCache(self,
                       timePattern="115*.jpg",
                       piId=0,
                       day=1,
                       classIds=[0, 2, 5, 7]):
     count = 0
     pi = self.pis[piId]
     piRepo = PiCamCacheRepo(pi)
     print(piRepo.getCamCacheDate(day))
     imgSrc = piRepo.getImgSrc(day, timePattern)
     while (True):
         imgInfo = piRepo.getImgInfoFromImgSrc(imgSrc)
         if (imgInfo is None):
             break
         objs = self.yoloNet.findDetectedObjects(imgInfo['img'])
         if objs is not None:
             print(count, imgInfo['timestamp'], 'imgInfo foundObjs -> ',
                   objs)
             for classId, _, _ in objs:
                 if classId in classIds:
                     yoloutil.drawObjs(imgInfo['timestamp'], imgInfo['img'],
                                       objs)
                     time.sleep(1)
                     break
         count = count + 1
     print('Total', count, 'searched')
Beispiel #2
0
def show_wdogfile(yoloNet, wdogFile):
    startTime, endTime, results = pyobjectfile.loadPyObject(wdogFile)
    print(startTime)
    print(endTime)
    if len(results) > 0:
        for result in results:
            channel, imgPath, timestamp, matches = result
            print("channel", channel,
                  [yoloutil.labelName(id) for id, _, _ in matches])
            img = nonopath.readNonoImg(imgPath, timestamp)
            yoloutil.drawObjs(imgPath, img, matches)
Beispiel #3
0
 def runCamMovement(self, channel=1, loop=3):
     detect = DiffYolo()
     for i in range(loop):
         try:
             imgInfo = getImgInfo(self.urlSnapshot, self.url, channel)
             ret = detect.run(self.yoloNet, imgInfo)
             foundObjs = imgInfo['foundObjs']
             print(i, 'imgInfo foundObjs -> ', foundObjs)
             if ret is not None:
                 print('*****', ret, DIFFDECODES[ret])
                 yoloutil.drawObjs('Diff', imgInfo['img'],
                                   imgInfo['foundObjs'])
             time.sleep(.1)
         except Exception as e:
             print('ex', e)
Beispiel #4
0
 def runCamMovement(self, piId=0, loop=3):
     pi = self.pis[piId]
     # detect = DiffYolo(trainedImageSize=(608, 608))
     objsDiff = imgdiff.ObjsDiff()
     for i in range(loop):
         try:
             imgInfo = getImgInfo(pi)
             objs = self.yoloNet.findDetectedObjects(imgInfo['img'])
             # foundObjs = imgInfo['foundObjs']
             # print(i, 'imgInfo foundObjs -> ', foundObjs)
             # ret = detect.run(self.yoloNet, imgInfo)
             # if ret is not None:
             #   print('*****', ret, DIFFDECODES[ret])
             if objs is not None and len(objs) > 0:
                 nDiff, objDiffs = objsDiff.metaDiff(objs)
                 if nDiff != 0 or imgdiff.evalObjDiffs(objDiffs):
                     print('---', objs, nDiff, objDiffs)
                     yoloutil.drawObjs('Diff', imgInfo['img'], objs)
             time.sleep(.5)
         except Exception as e:
             print('runMovement', e)
Beispiel #5
0
 def runTakeaLook(self):
     for imgInfo in self.getCamImgs():
         objs = self.yoloNet.findDetectedObjects(imgInfo['img'], (416, 416))
         print(objs)
         if objs is not None:
             yoloutil.drawObjs('CamImg', imgInfo['img'], objs)
Beispiel #6
0
 def runTakeaLook(self):
     for img in self.getPiImgs():
         objs = self.yoloNet.findDetectedObjects(img, (416, 416))
         print(objs)
         if objs is not None:
             yoloutil.drawObjs('PiImg', img, objs)
Beispiel #7
0
    import json
    import yoloutil
    jbConf = json.load(open("jbconf.json"))
    yoloNet = Yolo(jbConf["models"]["yolov3"])
    dir = "/tmp"
    # dir = '/Users/jb/ffmpeg-20191215-ed9279a-win64-static/cam/testimgs/'
    # jpgFiles = os.listdir(dir)
    jpgFiles = ["160001.jpg", 'testtrum.jpg', '10157976613_f1c8c34b07_z.jpg']
    jpgFiles = ["pi110.jpg", "pi115.jpg"]
    for jpg in jpgFiles:
        path = os.path.sep.join([dir, jpg])
        image = cv2.imread(path)
        objs = yoloNet.findDetectedObjects(image)
        print(objs)
        if objs is not None:
            yoloutil.drawObjs(path, image, objs)

DIFFDECODES = [
    'no early objs but found objs - some objs show up',  #0
    'some early objs but not found objs - something left',  #1
    'some early objs but not the same objs found',  #2
    'some early objs but less objs left',  #3
    'some early objs but more objs show',  #4
    'others'
]


class DiffYolo:
    def __init__(self, trainedImageSize=(320, 320)):
        self.trainedImageSize = trainedImageSize
        self.imgInfo = None