コード例 #1
0
 def detect(self, frame, count):
     image_url = f"./prueba/{count}.png"
     cv2.imwrite(os.path.join('./prueba', '%d.png') % count, frame)
     print(image_url)
     image = Image(self.yolo, image_url)
     detector = Detector(self.yolo, image)
     print(detector.detect())
コード例 #2
0
ファイル: report.py プロジェクト: xtreme-vikram-yadav/tern
def get_dockerfile_packages():
    '''Given a Dockerfile return an approximate image object. This is mosty
    guess work and shouldn't be relied on for accurate information. Add
    Notice messages indicating as such:
        1. Create an image with a placeholder repotag
        2. For each RUN command, create a package list
        3. Create layer objects with incremental integers and add the package
        list to that layer with a Notice about parsing
        4. Return stub image'''
    stub_image = Image('easteregg:cookie')
    layer_count = 0
    for inst in docker.docker_commands:
        if inst[0] == 'RUN':
            layer_count = layer_count + 1
            layer = ImageLayer(layer_count)
            install_commands, msg = common.filter_install_commands(inst[1])
            if msg:
                layer.origins.add_notice_to_origins(
                    inst[1], Notice(msg, 'info'))
            pkg_names = []
            for command in install_commands:
                pkg_names.append(common.get_installed_package_names(command))
            for pkg_name in pkg_names:
                pkg = Package(pkg_name)
                # shell parser does not parse version pins yet
                # when that is enabled, Notices for no versions need to be
                # added here
                layer.add_package(pkg)
    return stub_image
コード例 #3
0
    def detect(self, frame, count):
        image_with_extension = f"{count}.png"
        image_url = f"./prueba/{image_with_extension}"
        cv2.imwrite(os.path.join('./prueba', '%d.png') % count, frame)
        print(image_url)
        image = Image(self.yolo, image_url)
        detector = Detector(self.yolo, image)

        # si dentro de detector encuentro algo raro pues mando a llamar la api de aws
        array_of_labels = detector.detect()

        print(array_of_labels)

        if "cell phone" in array_of_labels:
            self.communication.post_image(image_url)
コード例 #4
0
def new_image():
    if request.method == 'POST':
        title = request.form['title']
        tags = request.form['tags']
        url = request.form['url']

        try:
            img = Image(title, tags, url)
        except Exception as e:
            return render_template("error.html", message=str(e))

        img.add_to_db(es)

        return render_template("success.html")
    else:
        return render_template("form.html")
コード例 #5
0
 def setUp(self):
     '''Test a generic Image class'''
     self.image = Image('debian:jessie')
コード例 #6
0
 def test_add_to_db(self):
     img = Image(self.img_name, self.img_tags, self.img_url)
     id = img.add_to_db(es, index=self.index_name)['_id']
     es.get(index=self.index_name, id=id)
     es.delete(index=self.index_name, id=id)
コード例 #7
0
 def test_image_success(self):
     img = Image(self.img_name, self.img_tags, self.img_url)
     assert (img.title == self.img_name
             and img.tags == self.img_tags.split(',')
             and img.url == self.img_url)