• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Python methods.denormalize函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中methods.denormalize函数的典型用法代码示例。如果您正苦于以下问题:Python denormalize函数的具体用法?Python denormalize怎么用?Python denormalize使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了denormalize函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。

示例1: update

    def update(self,frame,events):
        # TODO: leave this to a dependency plugin loader
        if any(isinstance(p,Scan_Path) for p in self.g_pool.plugins):
            if self.sp_active:
                pass
            else:
                self.set_bar_ok(True)
                self.sp_active = True
        else:
            if self.sp_active:
                self.set_bar_ok(False)
                self.sp_active = False
            else:
                pass

        img = frame.img
        img_shape = img.shape[:-1][::-1] # width,height

        filtered_gaze = []

        for gp1, gp2 in zip(events['pupil_positions'][:-1], events['pupil_positions'][1:]):
            gp1_norm = denormalize(gp1['norm_gaze'], img_shape,flip_y=True)
            gp2_norm = denormalize(gp2['norm_gaze'], img_shape,flip_y=True)
            x_dist =  abs(gp1_norm[0] - gp2_norm[0])
            y_dist = abs(gp1_norm[1] - gp2_norm[1])
            man = x_dist + y_dist
            # print "man: %s\tdist: %s" %(man,self.distance)
            if man < self.distance:
                filtered_gaze.append(gp1)
            else:
                # print "filtered"
                pass

        events['pupil_positions'][:] = filtered_gaze[:]
        events['pupil_positions'].sort(key=lambda x: x['timestamp']) #this may be redundant...
开发者ID:bischoff-b,项目名称:pupil,代码行数:35,代码来源:filter_fixations.py


示例2: on_button

 def on_button(window,button, action, mods):
     g_pool.gui.update_button(button,action,mods)
     pos = glfwGetCursorPos(window)
     pos = normalize(pos,glfwGetWindowSize(window))
     pos = denormalize(pos,(frame.img.shape[1],frame.img.shape[0]) ) # Position in img pixels
     for p in g_pool.plugins:
         p.on_click(pos,button,action)
开发者ID:PolaviejaLab,项目名称:pupil,代码行数:7,代码来源:main.py


示例3: recent_events

 def recent_events(self, events):
     frame = events.get("frame")
     if not frame:
         return
     pts = [
         denormalize(pt["norm_pos"], frame.img.shape[:-1][::-1], flip_y=True)
         for pt in events.get("gaze", [])
         if pt["confidence"] >= self.g_pool.min_data_confidence
     ]
     bgra = (self.b * 255, self.g * 255, self.r * 255, self.a * 255)
     for pt in pts:
         lines = np.array(
             [
                 ((pt[0] - self.inner, pt[1]), (pt[0] - self.outer, pt[1])),
                 ((pt[0] + self.inner, pt[1]), (pt[0] + self.outer, pt[1])),
                 ((pt[0], pt[1] - self.inner), (pt[0], pt[1] - self.outer)),
                 ((pt[0], pt[1] + self.inner), (pt[0], pt[1] + self.outer)),
             ],
             dtype=np.int32,
         )
         cv2.polylines(
             frame.img,
             lines,
             isClosed=False,
             color=bgra,
             thickness=self.thickness,
             lineType=cv2.LINE_AA,
         )
开发者ID:pupil-labs,项目名称:pupil,代码行数:28,代码来源:vis_cross.py


示例4: uroi_on_mouse_button

 def uroi_on_mouse_button(button, action, mods):
     if g_pool.display_mode == "roi":
         if action == glfw.GLFW_RELEASE and g_pool.u_r.active_edit_pt:
             g_pool.u_r.active_edit_pt = False
             # if the roi interacts we dont want
             # the gui to interact as well
             return
         elif action == glfw.GLFW_PRESS:
             x, y = glfw.glfwGetCursorPos(main_window)
             # pos = normalize(pos, glfw.glfwGetWindowSize(main_window))
             x *= hdpi_factor
             y *= hdpi_factor
             pos = normalize((x, y), camera_render_size)
             if g_pool.flip:
                 pos = 1 - pos[0], 1 - pos[1]
             # Position in img pixels
             pos = denormalize(
                 pos, g_pool.capture.frame_size
             )  # Position in img pixels
             if g_pool.u_r.mouse_over_edit_pt(
                 pos, g_pool.u_r.handle_size, g_pool.u_r.handle_size
             ):
                 # if the roi interacts we dont want
                 # the gui to interact as well
                 return
开发者ID:pupil-labs,项目名称:pupil,代码行数:25,代码来源:eye.py


示例5: recent_events

    def recent_events(self, events):
        frame = events.get("frame")
        if not frame:
            return
        falloff = self.falloff

        img = frame.img
        pts = [
            denormalize(pt["norm_pos"], frame.img.shape[:-1][::-1], flip_y=True)
            for pt in events.get("gaze", [])
            if pt["confidence"] >= self.g_pool.min_data_confidence
        ]

        overlay = np.ones(img.shape[:-1], dtype=img.dtype)

        # draw recent gaze postions as black dots on an overlay image.
        for gaze_point in pts:
            try:
                overlay[int(gaze_point[1]), int(gaze_point[0])] = 0
            except:
                pass

        out = cv2.distanceTransform(overlay, cv2.DIST_L2, 5)

        # fix for opencv binding inconsitency
        if type(out) == tuple:
            out = out[0]

        overlay = 1 / (out / falloff + 1)

        img[:] = np.multiply(
            img, cv2.cvtColor(overlay, cv2.COLOR_GRAY2RGB), casting="unsafe"
        )
开发者ID:pupil-labs,项目名称:pupil,代码行数:33,代码来源:vis_light_points.py


示例6: on_button

 def on_button(button, pressed):
     if not atb.TwEventMouseButtonGLFW(button,pressed):
         if pressed:
             pos = glfwGetMousePos()
             pos = normalize(pos,glfwGetWindowSize())
             pos = denormalize(pos,(img.shape[1],img.shape[0]) ) #pos in img pixels
             ref.detector.new_ref(pos)
开发者ID:pangshu2007,项目名称:CodeForRead,代码行数:7,代码来源:world.py


示例7: update

    def update(self,frame,recent_pupil_positions,events):

        falloff = self.falloff.value

        img = frame.img
        img_shape = img.shape[:-1][::-1]#width,height
        norm_gaze = [ng['norm_gaze'] for ng in recent_pupil_positions if ng['norm_gaze'] is not None]
        screen_gaze = [denormalize(ng,img_shape,flip_y=True) for ng in norm_gaze]


        overlay = np.ones(img.shape[:-1],dtype=img.dtype)

        # draw recent gaze postions as black dots on an overlay image.
        for gaze_point in screen_gaze:
            try:
                overlay[int(gaze_point[1]),int(gaze_point[0])] = 0
            except:
                pass

        out = cv2.distanceTransform(overlay,cv2.cv.CV_DIST_L2, 5)

        # fix for opencv binding incositency
        if type(out)==tuple:
            out = out[0]

        overlay =  1/(out/falloff+1)

        img *= cv2.cvtColor(overlay,cv2.COLOR_GRAY2RGB)
开发者ID:Azique,项目名称:pupil,代码行数:28,代码来源:vis_light_points.py


示例8: update

    def update(self,frame,events):
        if self.fill:
            thickness = -1
        else:
            thickness = self.thickness

        fixation_pts = [denormalize(pt['norm_pos'],frame.img.shape[:-1][::-1],flip_y=True) for pt in events.get('fixations',[])]
        not_fixation_pts = [denormalize(pt['norm_pos'],frame.img.shape[:-1][::-1],flip_y=True) for pt in events.get('gaze_positions',[])]


        if fixation_pts:
            for pt in fixation_pts:
                transparent_circle(frame.img, pt, radius=self.radius, color=(self.b, self.g, self.r, self.a), thickness=thickness)
        else:
            for pt in not_fixation_pts:
                transparent_circle(frame.img, pt, radius=7.0, color=(0.2, 0.0, 0.7, 0.5), thickness=thickness)
开发者ID:papr,项目名称:pupil,代码行数:16,代码来源:vis_fixation.py


示例9: recent_events

    def recent_events(self, events):
        frame = events.get("frame")
        if not frame:
            return
        if self.drag_offset is not None:
            pos = glfwGetCursorPos(glfwGetCurrentContext())
            pos = normalize(pos, glfwGetWindowSize(glfwGetCurrentContext()))
            pos = denormalize(
                pos, (frame.img.shape[1], frame.img.shape[0])
            )  # Position in img pixels
            self.pos[0] = pos[0] + self.drag_offset[0]
            self.pos[1] = pos[1] + self.drag_offset[1]

        if self.watermark is not None:
            # keep in image bounds, do this even when not dragging because the image sizes could change.
            self.pos[1] = max(
                0,
                min(frame.img.shape[0] - self.watermark.shape[0], max(self.pos[1], 0)),
            )
            self.pos[0] = max(
                0,
                min(frame.img.shape[1] - self.watermark.shape[1], max(self.pos[0], 0)),
            )
            pos = int(self.pos[0]), int(self.pos[1])
            img = frame.img
            roi = (
                slice(pos[1], pos[1] + self.watermark.shape[0]),
                slice(pos[0], pos[0] + self.watermark.shape[1]),
            )
            w_roi = slice(0, img.shape[0] - pos[1]), slice(0, img.shape[1] - pos[0])
            img[roi] = self.watermark[w_roi] * self.alpha_mask[w_roi] + img[roi] * (
                1 - self.alpha_mask[w_roi]
            )
开发者ID:pupil-labs,项目名称:pupil,代码行数:33,代码来源:vis_watermark.py


示例10: on_button

 def on_button(window,button, action, mods):
     if not atb.TwEventMouseButtonGLFW(button,action):
         pos = glfwGetCursorPos(window)
         pos = normalize(pos,glfwGetWindowSize(world_window))
         pos = denormalize(pos,(frame.img.shape[1],frame.img.shape[0]) ) # Position in img pixels
         for p in g_pool.plugins:
             p.on_click(pos,button,action)
开发者ID:foretama,项目名称:pupil,代码行数:7,代码来源:world.py


示例11: on_resize

 def on_resize(window,w, h):
     active_window = glfwGetCurrentContext()
     glfwMakeContextCurrent(window)
     norm_size = normalize((w,h),glfwGetWindowSize(window))
     fb_size = denormalize(norm_size,glfwGetFramebufferSize(window))
     atb.TwWindowSize(*map(int,fb_size))
     glfwMakeContextCurrent(active_window)
开发者ID:Esperadoce,项目名称:pupil,代码行数:7,代码来源:main.py


示例12: update

    def update(self, frame, events):
        img = frame.img
        img_shape = img.shape[:-1][::-1]  # width,height

        succeeding_frame = frame.index - self.prev_frame_idx == 1
        same_frame = frame.index == self.prev_frame_idx
        gray_img = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY)

        # vars for calcOpticalFlowPyrLK
        lk_params = dict(
            winSize=(90, 90), maxLevel=3, criteria=(cv2.TERM_CRITERIA_EPS | cv2.TERM_CRITERIA_COUNT, 20, 0.03)
        )

        updated_past_gaze = []

        # lets update past gaze using optical flow: this is like sticking the gaze points onto the pixels of the img.
        if self.past_gaze_positions and succeeding_frame:
            past_screen_gaze = np.array(
                [denormalize(ng["norm_pos"], img_shape, flip_y=True) for ng in self.past_gaze_positions],
                dtype=np.float32,
            )
            new_pts, status, err = cv2.calcOpticalFlowPyrLK(
                self.prev_gray, gray_img, past_screen_gaze, minEigThreshold=0.005, **lk_params
            )
            for gaze, new_gaze_pt, s, e in zip(self.past_gaze_positions, new_pts, status, err):
                if s:
                    # print "norm,updated",gaze['norm_gaze'], normalize(new_gaze_pt,img_shape[:-1],flip_y=True)
                    gaze["norm_pos"] = normalize(new_gaze_pt, img_shape, flip_y=True)
                    updated_past_gaze.append(gaze)
                    # logger.debug("updated gaze")

                else:
                    # logger.debug("dropping gaze")
                    # Since we will replace self.past_gaze_positions later,
                    # not appedning tu updated_past_gaze is like deliting this data point.
                    pass
        else:
            # we must be seeking, do not try to do optical flow, or pausing: see below.
            pass

        if same_frame:
            # paused
            # re-use last result
            events["gaze_positions"][:] = self.past_gaze_positions[:]
        else:
            # trim gaze that is too old
            if events["gaze_positions"]:
                now = events["gaze_positions"][0]["timestamp"]
                cutoff = now - self.timeframe
                updated_past_gaze = [g for g in updated_past_gaze if g["timestamp"] > cutoff]

            # inject the scan path gaze points into recent_gaze_positions
            events["gaze_positions"][:] = updated_past_gaze + events["gaze_positions"]
            events["gaze_positions"].sort(key=lambda x: x["timestamp"])  # this may be redundant...

        # update info for next frame.
        self.prev_gray = gray_img
        self.prev_frame_idx = frame.index
        self.past_gaze_positions = events["gaze_positions"]
开发者ID:masaii1224,项目名称:pupil,代码行数:59,代码来源:scan_path.py


示例13: current_mouse_pos

def current_mouse_pos(window, camera_render_size, frame_size):
    hdpi_fac = getHDPIFactor(window)
    x, y = glfwGetCursorPos(glfwGetCurrentContext())
    pos = x * hdpi_fac, y * hdpi_fac
    pos = normalize(pos, camera_render_size)
    # Position in img pixels
    pos = denormalize(pos, frame_size)
    return (int(pos[0]), int(pos[1]))
开发者ID:pupil-labs,项目名称:pupil,代码行数:8,代码来源:interactions.py


示例14: on_button

 def on_button(window, button, action, mods):
     g_pool.gui.update_button(button, action, mods)
     pos = glfw.glfwGetCursorPos(window)
     pos = normalize(pos, glfw.glfwGetWindowSize(main_window))
     # Position in img pixels
     pos = denormalize(pos, g_pool.capture.frame_size)
     for p in g_pool.plugins:
         p.on_click(pos, button, action)
开发者ID:samtuhka,项目名称:pupil,代码行数:8,代码来源:world.py


示例15: on_button

 def on_button(button, pressed):
     if not atb.TwEventMouseButtonGLFW(button,pressed):
         if pressed:
             pos = glfwGetMousePos()
             pos = normalize(pos,glfwGetWindowSize())
             pos = denormalize(pos,(frame.img.shape[1],frame.img.shape[0]) ) # Position in img pixels
             for p in g.plugins:
                 p.on_click(pos)
开发者ID:Flavsditz,项目名称:projects,代码行数:8,代码来源:world.py


示例16: gl_display

 def gl_display(self):
     if self.recent_fixation:
         fs = self.g_pool.capture.frame_size  # frame height
         pt = denormalize(self.recent_fixation["norm_pos"], fs, flip_y=True)
         draw_circle(
             pt, radius=48.0, stroke_width=10.0, color=RGBA(1.0, 1.0, 0.0, 1.0)
         )
         self.glfont.draw_text(pt[0] + 48.0, pt[1], str(self.recent_fixation["id"]))
开发者ID:pupil-labs,项目名称:pupil,代码行数:8,代码来源:fixation_detector.py


示例17: save_new_format

 def save_new_format(self, row, shape, flip):
     pos = [row['norm_pos_x'], row['norm_pos_y']]
     x, y = denormalize(pos, shape, flip_y=flip)
     #y = denormalize(row['norm_pos_y'], shape, flip_y=flip)
     #x = row['norm_pos_x']
     #y = row['norm_pos_y']
     self.ret.append((int(row['index']), row['confidence'], x, y))
     return True
开发者ID:BenYeh16,项目名称:SocialAR,代码行数:8,代码来源:getInfo.py


示例18: update

    def update(self,frame,recent_pupil_positions,events):
        img = frame.img
        self.img_shape = frame.img.shape

        if self.robust_detection.value:
            self.markers = detect_markers_robust(img,
                                                grid_size = 5,
                                                prev_markers=self.markers,
                                                min_marker_perimeter=self.min_marker_perimeter,
                                                aperture=self.aperture.value,
                                                visualize=0,
                                                true_detect_every_frame=3)
        else:
            self.markers = detect_markers_simple(img,
                                                grid_size = 5,
                                                min_marker_perimeter=self.min_marker_perimeter,
                                                aperture=self.aperture.value,
                                                visualize=0)

        # locate surfaces
        for s in self.surfaces:
            s.locate(self.markers)
            if s.detected:
                events.append({'type':'marker_ref_surface','name':s.name,'uid':s.uid,'m_to_screen':s.m_to_screen,'m_from_screen':s.m_from_screen, 'timestamp':frame.timestamp})

        if self.draw_markers.value:
            draw_markers(img,self.markers)

        # edit surfaces by user
        if self.surface_edit_mode:
            window = glfwGetCurrentContext()
            pos = glfwGetCursorPos(window)
            pos = normalize(pos,glfwGetWindowSize(window))
            pos = denormalize(pos,(frame.img.shape[1],frame.img.shape[0]) ) # Position in img pixels

            for s,v_idx in self.edit_surfaces:
                if s.detected:
                    pos = normalize(pos,(self.img_shape[1],self.img_shape[0]),flip_y=True)
                    new_pos =  s.img_to_ref_surface(np.array(pos))
                    s.move_vertex(v_idx,new_pos)

        #map recent gaze onto detected surfaces used for pupil server
        for s in self.surfaces:
            if s.detected:
                s.gaze_on_srf = []
                for p in recent_pupil_positions:
                    if p['norm_pupil'] is not None:
                        gp_on_s = tuple(s.img_to_ref_surface(np.array(p['norm_gaze'])))
                        p['realtime gaze on '+s.name] = gp_on_s
                        s.gaze_on_srf.append(gp_on_s)


        #allow surfaces to open/close windows
        for s in self.surfaces:
            if s.window_should_close:
                s.close_window()
            if s.window_should_open:
                s.open_window()
开发者ID:Azique,项目名称:pupil,代码行数:58,代码来源:marker_detector.py


示例19: update

    def update(self,frame,events):
        if self.fill:
            thickness = -1
        else:
            thickness = self.thickness

        pts = [denormalize(pt['norm_pos'],frame.img.shape[:-1][::-1],flip_y=True) for pt in events.get('gaze_positions',[]) if pt['confidence']>=self.g_pool.min_data_confidence]
        for pt in pts:
            transparent_circle(frame.img, pt, radius=self.radius, color=(self.b, self.g, self.r, self.a), thickness=thickness)
开发者ID:samtuhka,项目名称:pupil,代码行数:9,代码来源:vis_circle.py


示例20: on_pos

 def on_pos(window, x, y):
     x, y = x * hdpi_factor, y * hdpi_factor
     g_pool.gui.update_mouse(x, y)
     pos = x, y
     pos = normalize(pos, g_pool.camera_render_size)
     # Position in img pixels
     pos = denormalize(pos, g_pool.capture.frame_size)
     for p in g_pool.plugins:
         p.on_pos(pos)
开发者ID:pupil-labs,项目名称:pupil,代码行数:9,代码来源:player.py



注:本文中的methods.denormalize函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python methods.normalize函数代码示例发布时间:2022-05-27
下一篇:
Python meterbus.load函数代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap