Example #1
0
    def UpdateGUI(self):
        Trigger = 0
        while 1:
            self.sku_weight_label.setText(str(self.Scale.weight) + 'kg')
            if self.Scale.state == 0:
                self.set_image(self.first_candidate_image, 'welcome.jpg')
                self.set_image(self.second_candidate_image, 'blank.jpg')
                self.set_image(self.third_candidate_image, 'blank.jpg')
                self.set_image(self.forth_candidate_image, 'blank.jpg')
                self.set_name(self.sku_name_label, ' ')
                self.set_name(self.sku_price_label, '0.0元')

                Trigger = 0
            if self.Scale.state == 2 and Trigger == 0:
                start_time = time.time()
                image = camera.open_camera()
                test = camera.predict(image)
                print(time.time() - start_time)
                self.send_results(test, self.Scale.weight)
                Trigger = 1

            if self.second_candidate_image.changeFlag == 1:
                self.set_name(
                    self.sku_price_label,
                    str(self.second_candidate_image.now_candidate_price) + '元')
                self.set_image(
                    self.first_candidate_image,
                    self.second_candidate_image.now_candidate_image_path)
                self.set_name(self.sku_name_label,
                              self.second_candidate_image.now_candidate_name)

                self.third_candidate_image.changeFirstPath(
                    self.second_candidate_image.now_candidate_image_path,
                    self.second_candidate_image.now_candidate_price,
                    self.second_candidate_image.now_candidate_name)
                self.forth_candidate_image.changeFirstPath(
                    self.second_candidate_image.now_candidate_image_path,
                    self.second_candidate_image.now_candidate_price,
                    self.second_candidate_image.now_candidate_name)
                self.second_candidate_image.pathChange()
                self.second_candidate_image.changeFlag = 0

            elif self.third_candidate_image.changeFlag == 1:
                self.set_name(
                    self.sku_price_label,
                    str(self.third_candidate_image.now_candidate_price) + '元')
                self.set_image(
                    self.first_candidate_image,
                    self.third_candidate_image.now_candidate_image_path)
                self.set_name(self.sku_name_label,
                              self.third_candidate_image.now_candidate_name)
                self.second_candidate_image.changeFirstPath(
                    self.third_candidate_image.now_candidate_image_path,
                    self.third_candidate_image.now_candidate_price,
                    self.third_candidate_image.now_candidate_name)
                self.forth_candidate_image.changeFirstPath(
                    self.third_candidate_image.now_candidate_image_path,
                    self.third_candidate_image.now_candidate_price,
                    self.third_candidate_image.now_candidate_name)
                self.third_candidate_image.pathChange()
                self.third_candidate_image.changeFlag = 0

            elif self.forth_candidate_image.changeFlag == 1:
                self.set_name(
                    self.sku_price_label,
                    str(self.forth_candidate_image.now_candidate_price) + '元')
                self.set_name(self.sku_name_label,
                              self.forth_candidate_image.now_candidate_name)
                self.set_image(
                    self.first_candidate_image,
                    self.forth_candidate_image.now_candidate_image_path)
                self.second_candidate_image.changeFirstPath(
                    self.forth_candidate_image.now_candidate_image_path,
                    self.forth_candidate_image.now_candidate_price,
                    self.forth_candidate_image.now_candidate_name)
                self.third_candidate_image.changeFirstPath(
                    self.forth_candidate_image.now_candidate_image_path,
                    self.forth_candidate_image.now_candidate_price,
                    self.forth_candidate_image.now_candidate_name)
                self.forth_candidate_image.pathChange()
                self.forth_candidate_image.changeFlag = 0
Example #2
0
                print(cid, score, bbox)
                tag = "{}; {:.4f}".format(cname, score)
                cv2.rectangle(frame, (x, y), (w, h), (0, 255, 0), 2)
                cv2.putText(frame, tag, (x, y - 20), cv2.FONT_HERSHEY_SIMPLEX,
                            0.6, (0, 0, 255), 1)

            # print(bounding_boxes[0][0][2], bounding_boxes[0][0][3])
            # cv2.rectangle(frame,(384,0),(510,128),(0,255,0),3)
            displayBuf = frame
            cv2.imshow(windowName, displayBuf)
            cv2.waitKey(0)

    else:
        print("camera open failed")


if __name__ == '__main__':
    arguments = parse_cli_args()
    print("Called with args:")
    print(arguments)
    print("OpenCV version: {}".format(cv2.__version__))
    print("Device Number:", arguments.video_device)
    if arguments.video_device == -1:
        video_capture = camera.open_camera(device_number=None)
    else:
        video_capture = camera.open_camera(
            device_number=arguments.video_device)
    read_cam(video_capture)
    video_capture.release()
    cv2.destroyAllWindows()
Example #3
0
    i = 0
    while i < n:
        print("[", i, "]", devices[i])
        i += 1

    select = select_camera(i - 1)
    print("You have select camera(%d)" % (select))

    # is dual camera? default Yes.
    print("Is it dual camera?")
    dual_cam = input("[Y/N]:")
    if dual_cam == "N" or dual_cam == "n":
        isDualCam = False

    cap = camera.open_camera(select)
    if cap.isOpened():
        width = cap.get(3)  # Frame Width
        height = cap.get(4)  # Frame Height
        print('Default width: ' + str(width) + ', height: ' + str(height))

        plt.axis([0, 100, 0, 255])
        plt.ion()  #开启interactive模式
        xs = [0, 0]
        ys = [1, 1]
        i = 0

        while True:
            ret, frame = cap.read()
            # cv2.imshow("frame", frame)
            if isDualCam: