Пример #1
0
    def getPhotoObject(self):
        os.chdir('..')
        execution_path = os.getcwd()
        detector = ObjectDetection()
        detector.setModelTypeAsYOLOv3()
        detector.setModelPath(os.path.join(execution_path, "yolo.h5"))
        detector.loadModel()

        media_path = self.navigateToMediaDir()

        photos = {}
        for name in os.listdir('.'):
            with open(name, "r") as read_file:
                data = json.load(read_file)

                for key in data['photos']:
                    detection_types = self.getObjectTypes(
                        detector, media_path, key['uri'])
                    geolocation = GeoLocation()
                    geo_loc = geolocation.getLongLatFromIP(
                        str(key['media_metadata']['photo_metadata']
                            ['upload_ip']))
                    photos[str(key['uri']).split('/')[2]] = {
                        'category': data['name'],
                        'uri': str(key['uri']).split('/')[2],
                        'geo': geo_loc,
                        'detection_types': detection_types
                    }
        return photos