I'd tried several techniques, but can't get image from iSight.
Probably, I just need to create appropriate processing callback.
# -*- coding: utf-8 -*-
from pyglet.libs.darwin import *
from pyglet.image.codecs.quicktime import *
from pyglet.image.codecs.quicktime import _oscheck, _name
# EnterMovies
quicktime.EnterMovies()
# TODO: Enumerate cams
# Get Grab component
SeqGrabComponentType = _name('barg')
camera = ComponentInstance(quicktime.OpenDefaultComponent
(SeqGrabComponentType, 0))
# Initialize cam
_oscheck(quicktime.SGInitialize(camera))
# Set mode (?)
seqGrabDontMakeMovie = 32
_oscheck(quicktime.SGSetDataRef(camera, 0, 0, seqGrabDontMakeMovie)) #
XXX: + seqGrabToMemory?
# Create video channel
SGChannel = ComponentInstance
VideoMediaType = _name('vide') # Movies.h
channel = SGChannel()
_oscheck(quicktime.SGNewChannel(camera, VideoMediaType, byref
(channel)))
# Set channel bounds
boundsRect = Rect()
boundsRect.top = 0
boundsRect.left = 0
boundsRect.bottom = 80
boundsRect.right = 100
_oscheck(quicktime.SGSetChannelBounds(channel, byref(boundsRect)))
# Create GWorld
gWorld = GWorldPtr()
_oscheck(quicktime.QTNewGWorld(byref(gWorld), k32ARGBPixelFormat, byref
(boundsRect), 0, 0, 0))
# Get GWorld pixmap
PixMapHandle = c_void_p
pixmap = PixMapHandle(quicktime.GetGWorldPixMap(gWorld))
# Calculate buffer size for image content
width_bytes = quicktime.GetPixRowBytes(pixmap)
height = boundsRect.bottom
buffer_size = width_bytes * height
# Bind camera to gWorld
device = quicktime.GetMainDevice() # or 0
_oscheck(quicktime.SGSetGWorld(camera, gWorld, device))
# Set channel usage?
seqGrabRecord = 1
_oscheck(quicktime.SGSetChannelUsage(channel, seqGrabRecord))
# Set data procedure
#qt.SGSetDataProc(cam, 0, 0) # process_data_callback
# Prepare camera
_oscheck(quicktime.SGPrepare(camera, 0, 1))
# Start record
_oscheck(quicktime.SGStartRecord(camera))
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"pyglet-users" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/pyglet-users?hl=en
-~----------~----~----~----~------~----~------~--~---