示例#1
0
    def threadFn(self):
        while True:
            refImg, refBox, refClasses, pBoxes, pClasses, pScores, pProposals, pProposalScores, pAllBoxes, pAllScores, pAllClasses = self.queue.get(
            )
            refImg = refImg[0]

            a = Visualize.drawBoxes(refImg, refBox, refClasses,
                                    self.dataset.getCaptions(refClasses),
                                    self.palette)
            b = Visualize.drawBoxes(refImg,
                                    pBoxes,
                                    pClasses,
                                    self.dataset.getCaptions(pClasses),
                                    self.palette,
                                    scores=pScores)
            c = Visualize.drawBoxes(refImg,
                                    pProposals,
                                    None,
                                    None,
                                    self.palette,
                                    scores=pProposalScores * 0.3)
            d = Visualize.drawBoxes(refImg,
                                    pAllBoxes,
                                    pAllClasses,
                                    self.dataset.getCaptions(pAllClasses),
                                    self.palette,
                                    scores=pAllScores)

            preview = Visualize.tile(
                2, 2, [a, b, c, d],
                ["input", "output", "proposals", "all detections"])

            cv2.imwrite(self.opt.name + "/preview/preview.jpg", preview)

            self.queue.task_done()
示例#2
0
            sess, opt.n, None, ignoreVarsInFileNotInSess=True):
        print("Failed to load network.")
        sys.exit(-1)

    while True:
        img = input.get()
        if img is None:
            break

        img = preprocessInput(img)

        rBoxes, rScores, rClasses = sess.run(
            [boxes, scores, classes],
            feed_dict={image: np.expand_dims(img, 0)})

        res = Visualize.drawBoxes(img,
                                  rBoxes,
                                  rClasses,
                                  [categories[i] for i in rClasses.tolist()],
                                  palette,
                                  scores=rScores)

        output.put(input.getName(), res)

        if opt.p == 1:
            cv2.imshow("result", res)
            if opt.o == "":
                cv2.waitKey(input.getDelay() if opt.delay < 0 else opt.delay)
            else:
                cv2.waitKey(1)