2014-12-24 7 views
0

나는 wxPython에 내장 된 Pygame.camera을 만들려고했습니다.wxpython의 Pygame.camera

일부 검색 후 SDL_WINDOWID로 확인할 수 있습니다. 하지만 난 할 conldn't 그것을

이미지가 내 목표 (내가 만들고 싶어 무엇을) http://kalten.tistory.com/entry/wxPython

당신이 날 도와 줄 수있다? 나는

감사합니다 Simplecv (안 pygame.camera)와 카메라 뷰어 !!! ^^ Pygame Tutorials Camera Module Introduction에서 좋은 하루

self.parent = parent 
    self.hwnd = self.GetHandle() 
    os.environ['SDL_VIDEODRIVER'] = 'windib' 
    os.environ['SDL_WINDOWID'] = str(self.hwnd) 

답변

0

을 경우에도

가 난 상관 없어 그냥 간단한 예제가 필요합니다 :

라이브 스트림 캡처이 튜토리얼의 나머지 부분은 을 기반으로하여 이미지의 라이브 스트림을 캡처합니다. 이를 위해 아래의 클래스를 사용합니다. 설명했듯이, 화면에 균등하게 카메라 프레임의 스트림을 블리팅하여 효과적으로 라이브 비디오를 보여줍니다. 기본적으로 당신이 무엇을 기대하고, get_image()를 루핑하고, 디스플레이 표면에 블리 팅하고, 뒤집습니다. 성능상의 이유로 매번 사용할 동일한 서페이스로 카메라를 공급하는 이됩니다.

class Capture(object): 
    def __init__(self): 
     self.size = (640,480) 
     # create a display surface. standard pygame stuff 
     self.display = pygame.display.set_mode(self.size, 0) 

     # this is the same as what we saw before 
     self.clist = pygame.camera.list_cameras() 
     if not self.clist: 
      raise ValueError("Sorry, no cameras detected.") 
     self.cam = pygame.camera.Camera(self.clist[0], self.size) 
     self.cam.start() 

     # create a surface to capture to. for performance purposes 
     # bit depth is the same as that of the display surface. 
     self.snapshot = pygame.surface.Surface(self.size, 0, self.display) 

    def get_and_flip(self): 
     # if you don't want to tie the framerate to the camera, you can check 
     # if the camera has an image ready. note that while this works 
     # on most cameras, some will never return true. 
     if self.cam.query_image(): 
      self.snapshot = self.cam.get_image(self.snapshot) 

     # blit it to the display surface. simple! 
     self.display.blit(self.snapshot, (0,0)) 
     pygame.display.flip() 

    def main(self): 
     going = True 
     while going: 
      events = pygame.event.get() 
      for e in events: 
       if e.type == QUIT or (e.type == KEYDOWN and e.key == K_ESCAPE): 
        # close the camera safely 
        self.cam.stop() 
        going = False 

      self.get_and_flip() 
get_image 이후

()는 느린 카메라 시간이 꽤 걸릴 수있는 차단 호출입니다,이 예제는 카메라가 준비되어 있는지 확인하기 위해 query_image()를 사용합니다. 이렇게하면 게임의 프레임 속도를 카메라의 프레임 속도와 분리 할 수 ​​있습니다. 카메라가 query_image() 함수를 올바르게 지원하지 않는다면 거의 동일한 성능 향상을 위해 카메라를 이미지를 별도의 스레드로 캡처하도록 할 수도 있습니다.