home *** CD-ROM | disk | FTP | other *** search
- #pragma once
- // © Paul B. Beeken, Work In Progress, 1994-5
- // Knowledge Software Consulting.
- //
- // Please, please, please, in the unlikely event you should use this stuff
- // for some commercial application I would appreciate you contacting me. If
- // its for your own use, use away. Send email: knowsoft@ios.com
- // My personal philosophy closely adheres to that of GNU software. I offer this
- // in the hope that others will improve and expand upon it. Post your additions,
- // leave this notice in place and add your own comments.
- //
- // As always: this file is presented as is with no warrantees expressed or implied.
- // Swim at your own risk, etc. etc.
- //
- // CQuickCam
- //
- // A c++ object library for the Connectix QuickCam using the
- // standardized vdig functions outlined in the Ch. 8 of QTComponents.
- // Yeah, you could do much of this seamlessly with Ch. 6 but with alot
- // of loss of control and performance. Some considerable experimentation
- // has gone into this object and many related threads along this line.
- // I think this provides the best trade off of flexability and control
- //
- // Notes in general: There are sometimes many ways to handle the
- // output of a vdig. It can preview directly to the screen (if it is
- // a cGrafPort) or to a pixmap. Multiple buffering is an option and
- // can be a very effective method given the serial data stream nature of
- // this kind of digitizer. It can allow the greatest flexability
- // and smoothness of updating. It may not be the best solution for a
- // particular application.
- //
- // QuickCam in particular:
- // The B&W camera is a 4 bit machine whose vdig doesn't do DMA.
- // This object always buffers the data and the instatiator is responsible
- // for updating. Previewing is done by copying the GWorld pixmap to a
- // rectangle in a given cGrafport. There are a couple of ways to accumulate
- // data to the pixMap. One is to use a buffers and the other is to write
- // to a pixmap. The former allows async grabs while the later does not.
- // The routines outlined here allow either. By specifying 0 for buffers,
- // the vdig writes directly to the pixmap without any overhead associated
- // with buffers. Any value from 1 to 3 will allow you to write to different
- // rectangles in the same pixmap but will allow async grabs. This may
- // allow for some performance imporvements.
- // The QuickCam vdig doesn't seem to like more than 3 buffers. Why would you
- // need more? Actually this makes sense. One would be the writethrubuffer
- // the other two are the alternating capture buffers.
- //
- //
- // Current version 0.8 © Paul B. Beeken, Knowledge Software Consulting.
- //
- // 11/08/95 Finished basic object after creating various types of LPane
- // derivatives. This object borrows the from the best of them. Its
- // creation also eliminates the dependance on MW PowerPlant.
- // 12/04/95 Completed spot metering and fixed a memory leak.
- //
- // Wishlist: Sequential capture to moov.
- // Include methods for capturing from a subset rect in vdig bounds.
- // Motion triggering.
-
- #include <quicktimeComponents.h>
-
- enum {
- modemPort = 0,
- printerPort
- };
-
-
- class CQuickCam {
- public:
-
- CQuickCam( short inSrc=modemPort, short nBuffers=1 );
- ~CQuickCam( void );
-
- // These methods control the digitizer.
- // update the video buffer.
- void UpdateVideo( void );
- // draw the of the last filled buffer to a rect within the given port
- void DrawVideo( CGrafPtr gw, const Rect& r );
- // optimize the video Rect to r.
- Rect OptVideoRect( const Rect& r ); // sets vdig rect to optimal size for given Rect.
- // returns it for use by caller.
- // Get and set the brighness.
- void Brightness( unsigned short v );
- unsigned short Brightness( void );
- void SpotMeter( unsigned short b ); // Set target brightness
- void SpotMeter( const Rect& r ); // Spot meter in r
-
- // Choose the input source (0:modem, 1:printer);
- void InputSource( short src );
- short InputSource( void );
-
- // Set default video characteristics
- void SetDefaults( void );
-
- // Grab a pict.
- PicHandle GrabPict( void );
- // We need to be able to instantiate and add sequences to a moov file.
- // to be continued...
-
- // Return the current InfoRecord.
- DigitizerInfo GetInfoRecord( void );
-
- protected:
- void SetUpBuffers( short n=1 );
- void ClearUpBuffers( void );
-
- private: // for exposure only, don't play unless you know what's going on.
- short bufferCount;
- short bufferIndex;
-
- VideoDigitizerComponent vdig; // Instance of a vdig
- DigitizerInfo vdigInfo; // Information
- GWorldPtr gWorld; // gWorld for capture (could be current port)
-
- Rect videoFrame;
- MatrixRecord videoMatrix;
- float bright;
-
- };