Jump to content

OpenCv com wxGlade


SilvJ

Recommended Posts

Boa Noite,

O meu objectivo é ter uma pequena interface em que apareca a partir da biblioteca opencv uma captura da imagem da webcam.

Isso eu já consigo, mas o meu problema é que tenho a frame do wx e depois a imagem da webcam ocupa-me muito espaço da frame e quero pô-la mais pequena para isso utilizei o seguinte:

cv.SetCaptureProperty( self.capture, cv.CV_CAP_PROP_FRAME_WIDTH, 320 );
cv.SetCaptureProperty( self.capture, cv.CV_CAP_PROP_FRAME_HEIGHT, 240 );

A

Aqui vái a parte principal do código:

def __init__(self, parent):
wx.Frame.__init__(self, parent, -1, title="Live Camera Feed")

self.SetDoubleBuffered(True)
self.capture = None
self.bmp = None
#self.displayPanel = wx.Panel(self,-1)

#set up camaera init
self.capture = cv.CaptureFromCAM(0)
cv.SetCaptureProperty( self.capture, cv.CV_CAP_PROP_FRAME_WIDTH, 320 );
cv.SetCaptureProperty( self.capture, cv.CV_CAP_PROP_FRAME_HEIGHT, 240 );
frame = cv.QueryFrame(self.capture)
if frame:
  cv.CvtColor(frame,frame,cv.CV_BGR2RGB)
  self.bmp = wx.BitmapFromBuffer(frame.width,frame.height,frame.tostring())
  self.SetSize((800,600))
self.displayPanel = wx.Panel(self,-1)

self.fpstimer = wx.Timer(self)
self.fpstimer.Start(1000/self.fps)
self.Bind(wx.EVT_TIMER, self.onNextFrame, self.fpstimer)
self.Bind(wx.EVT_PAINT, self.onPaint)

self.Show(True)

 def updateVideo(self):
frame = cv.QueryFrame(self.capture)
if frame:
  cv.CvtColor(frame,frame,cv.CV_BGR2RGB)
  self.bmp.CopyFromBuffer(frame.tostring())
  self.Refresh()

O que acontece é que se altero o size para mais pequeno deixa de me aparecer imagem fica a preto.

Se alguem me puder ajudar agradecia. Cumps

Edited by SilvJ
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...

Important Information

By using this site you accept our Terms of Use and Privacy Policy. We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.