Пример #1
0
 def __init__(self, can, poids, coeff, py0, px0):
     self.can = can
     self.poids = poids
     self.py0 = py0
     self.px0 = px0
     self.py = py0
     self.px = px0
     self.coeff = coeff
     self.moov = 0
     self.timer = MyTimer(0.001, self.deplace)
Пример #2
0
    def get_camera_images(self):
        '''
            截取摄像头图片,存入全局变量中
        '''
        reactTimer = MyTimer()
        waitTimer = MyTimer()
        reactTime = 0.5
        imageSize = (640, 480)
        images = []
        reactTime = int(reactTime * 1000)
        reactTimer.start(reactTime)
        waitTime = 100

        while reactTimer.isTimeOut() == False:
            waitTimer.start(waitTime)
            flag, image = self.cap.read()
            image = cv2.resize(image, imageSize)
            images.append(image)
            waitTimer.waitTimeOut()

        gl.GL_Images = images
        gl.GL_Images_Length = images.__len__()
        print("length={}".format(images.__len__()))
            lsqe = el.LSqEllipse()
            lsqe.fit(data)
            center, width, height, phi = lsqe.parameters()
            a = max(width, height)
            b = min(width, height)
            area = math.pi * a * b
            eccentricity = pow((1 - (b / a)**2), 1 / 2)
            pore_opening_degree = b / a
            return a, b, area, eccentricity, pore_opening_degree


if __name__ == "__main__":
    import os
    base_path = r"C:\Users\LJY\Desktop\第一篇小论文-第二阶段\cropped_stomata\cropped_det"
    # 计时开始
    mytime = MyTimer.MyTimer()
    mytime.start()

    # 先统计一下
    path = r"D:\Mask_RCNN\mask_rcnn\cropped_stomata\first_time"
    # image_num 是 f
    image_num = len([
        lists for lists in os.listdir(path)
        if os.path.isdir(os.path.join(path, lists))
    ])
    # pore_num 是 s,表示总共有多少个匹配气孔
    pore_num = 0
    for img in range(image_num):
        dirname = r"D:\Mask_RCNN\mask_rcnn\cropped_stomata\first_time\{}".format(
            img)
        filenum = len([
Пример #4
0
   print __name__, "start ..."

   max = 20      

   fig = plt.figure()
   ax = fig.add_subplot(111)
   # some X and Y data
   li, = ax.plot(x, y, 'r.')
   # draw and show it
   fig.canvas.draw()
   plt.ylim((-5,25))
   plt.show(block=False)

   HOST, PORT = "192.168.0.123", 9998

   timer = MyTimer.MyTimer()

   print timer
   
   print "start server"
   # Create the server, binding to localhost on port 9999
   server = SocketServer.TCPServer((HOST, PORT), MyTCPHandler)
   server_thread = threading.Thread(target=server.serve_forever)
   # Exit the server thread when the main thread terminates
   server_thread.daemon = True
   server_thread.start()
   
   print "start drawer"
   drawer = PlotDrawer()
   drawer_thread = threading.Thread(target=drawer.run)
   # Exit the server thread when the main thread terminates
Пример #5
0
    def run(self):
        #获取全局变量数据并更新全局数据
        self.info = gl.GL_VInfo
        self.model = gl.GL_Model
        self.isEnd = False
        gl.GL_TalScore = 0
        #清空全局队列
        while gl.GL_CurScoreQueue.empty() == False:
            gl.GL_CurScoreQueue.get()

        startTimer = MyTimer()
        startTimer.start(1000)  #开始计时
        temp = 0

        for oneInfo in self.info:

            timeid = oneInfo['timeid']  #演示视频播放时间ms
            reactime = float(oneInfo['reactime'])  #反应时间
            poseSocre = oneInfo['score']  #分数
            posepoints = oneInfo['posepoints']  #关节点信息
            posepoints = mxnet.nd.array(posepoints)  #类型转换
            temp += 1
            print('*************这是第{}次'.format(temp))
            print("timeid={}".format(timeid))
            startTimer.resetWaitTime(timeid)  #设置等待时间
            startTimer.waitTimeOut()  #等待时间,相当于 sleep

            self.now_to_getImages.emit()  #发送截取视频图像的信号

            #等待截取的图片存入全局变量
            while bool(gl.GL_Images == []) | bool(
                    gl.GL_Images.__len__() < gl.GL_Images_Length):
                if self.isEnd == True:  #当需要线程关闭时,退出
                    break
                time.sleep(0.02)
            if self.isEnd == True:  #当需要线程关闭时,退出
                break

            images = gl.GL_Images  #获取全局变量 (截取的图片list)
            #跟新全局变量数据
            gl.GL_Images = []
            gl.GL_Images_Length = 0

            use_gpu = False
            maxScore = 0
            score = 0

            #给每一个图片匹配示范骨架,获取最大分数
            for image in images:
                if self.isEnd == True:
                    break
                playerPre, playerImage = net.detection(self.model, image,
                                                       use_gpu)  #模型预测骨架
                if playerPre != None:
                    playerDis, playerSkeleton = tools.normalization(
                        playerPre['pred_coords'][0])  #结果归一化
                    score = tools.matching(playerSkeleton,
                                           posepoints,
                                           use_gpu=use_gpu)  #计算匹配结果
                if maxScore < score:
                    maxScore = score

            if self.isEnd == True:
                break
            print("mxScore={}".format(maxScore))

            #当分数超过10,认定匹配成功
            if maxScore > 10:
                #将分数更新在全局变量中
                gl.GL_CurScoreQueue.put(poseSocre)
                gl.GL_TalScore += poseSocre

                self.update_date.emit(poseSocre)  #发送信号,传递动作得分
            else:
                self.update_date.emit(0)  #发送信号,传递动作得分

        startTimer.end()
# |-test
# |-|-test
# |-|-|-***.png
# |-|=annotations
# |-|-|-***.json
dataset_test.load_coco(r"D:\Mask_RCNN\mask_rcnn\测试银杏的参数数据集\test2017",
                       "test2017")
dataset_test.prepare()
# image_ids 是记录test_datasets中共有多少张图片
image_ids = dataset_test.image_ids
IoU_all_photos = np.zeros((1, len(image_ids)))
all_statistic = np.zeros((2, len(image_ids)))
count_statistic = np.zeros((2, len(image_ids)))

# 计时
t1 = MyTimer.MyTimer()
t1.start()
# 测试集
for f in range(len(image_ids)):
    image_id = f

    info = dataset_test.image_info[image_id]
    print("image ID: {}.{} ({}) {}".format(
        info["source"], info["id"], image_id,
        dataset_test.image_reference(image_id)))
    # 原demo在使用图像之前已经对图像进行了裁剪 具体代码在model的1224行
    image, image_meta, gt_class_id, gt_bbox, gt_mask = modellib.load_image_gt(
        dataset_test, config, image_id, use_mini_mask=False)
    # image 是 3D图像 [image]是4-D列表 len([image]) = 1 [image]代表把整个图像作为一个batch处理
    results = model.detect([image], verbose=1)
    # 这里的model.detect