reference

This documentation is automatically generated from the openFrameworks source code using doxygen and refers to the most recent release, version 0.12.0.

ofVideoGrabber.h
Go to the documentation of this file.
1#pragma once
2
3#include "ofTexture.h"
4#include "ofVideoBaseTypes.h"
5
6template<typename T>
7class ofPixels_;
12
13
15
16 public :
17
19 virtual ~ofVideoGrabber();
20
21 std::vector<ofVideoDevice> listDevices() const;
22 bool isFrameNew() const;
23 void update();
24 void close();
25 bool setup(int w, int h){return setup(w,h,bUseTexture);}
26 bool setup(int w, int h, bool bTexture);
27 OF_DEPRECATED_MSG("Use setup instead",bool initGrabber(int w, int h){return setup(w,h);})
28 OF_DEPRECATED_MSG("Use setup instead",bool initGrabber(int w, int h, bool bTexture));
29
30 bool setPixelFormat(ofPixelFormat pixelFormat);
32
33 void videoSettings();
35 const ofPixels& getPixels() const;
36 OF_DEPRECATED_MSG("Use getPixels() instead", ofPixels& getPixelsRef());
37 OF_DEPRECATED_MSG("Use getPixels() instead", const ofPixels& getPixelsRef() const);
39 const ofTexture & getTexture() const;
40 OF_DEPRECATED_MSG("Use getTexture",ofTexture & getTextureReference());
41 OF_DEPRECATED_MSG("Use getTexture",const ofTexture & getTextureReference() const);
42 std::vector<ofTexture> & getTexturePlanes();
43 const std::vector<ofTexture> & getTexturePlanes() const;
44 void setVerbose(bool bTalkToMe);
45 void setDeviceID(int _deviceID);
46 void setDesiredFrameRate(int framerate);
47 void setUseTexture(bool bUse);
48 bool isUsingTexture() const;
49 void draw(float x, float y, float w, float h) const;
50 void draw(float x, float y) const;
52
53 void bind() const;
54 void unbind() const;
55
56 //the anchor is the point the image is drawn around.
57 //this can be useful if you want to rotate an image around a particular point.
58 void setAnchorPercent(float xPct, float yPct); //set the anchor as a percentage of the image width/height ( 0.0-1.0 range )
59 void setAnchorPoint(float x, float y); //set the anchor point in pixels
60 void resetAnchor(); //resets the anchor to (0, 0)
61
62 float getHeight() const;
63 float getWidth() const;
64
65 bool isInitialized() const;
66
67 void setGrabber(std::shared_ptr<ofBaseVideoGrabber> newGrabber);
68 std::shared_ptr<ofBaseVideoGrabber> getGrabber();
69 const std::shared_ptr<ofBaseVideoGrabber> getGrabber() const;
70
71 template<typename GrabberType>
72 std::shared_ptr<GrabberType> getGrabber(){
73 return std::dynamic_pointer_cast<GrabberType>(getGrabber());
74 }
75
76 template<typename GrabberType>
77 const std::shared_ptr<GrabberType> getGrabber() const{
78 return std::dynamic_pointer_cast<GrabberType>(getGrabber());
79 }
80
81 private:
82
83 std::vector<ofTexture> tex;
84 bool bUseTexture;
85 std::shared_ptr<ofBaseVideoGrabber> grabber;
86 int requestedDeviceID;
87
88 mutable ofPixelFormat internalPixelFormat;
89 int desiredFramerate;
90};
91
92
93
virtual void draw(float x, float y) const
Draw at a position at the native size.
Definition ofGraphicsBaseTypes.h:150
A base class representing a drawable video source.
Definition ofVideoBaseTypes.h:103
A base class representing a video device such as a camera.
Definition ofVideoBaseTypes.h:110
A class representing a collection of pixels.
Definition ofPixels.h:170
A wrapper class for an OpenGL texture.
Definition ofTexture.h:253
Definition ofVideoGrabber.h:14
std::vector< ofVideoDevice > listDevices() const
Get a list of available video grabber devices.
Definition ofVideoGrabber.cpp:154
ofPixels & getPixels()
Get a reference to the underlying ofPixels.
Definition ofVideoGrabber.cpp:186
virtual ~ofVideoGrabber()
Definition ofVideoGrabber.cpp:61
void draw(float x, float y, float w, float h) const
Draw at a position with the specified size.
Definition ofVideoGrabber.cpp:325
OF_DEPRECATED_MSG("Use getPixels() instead", const ofPixels &getPixelsRef() const)
std::shared_ptr< ofBaseVideoGrabber > getGrabber()
Definition ofVideoGrabber.cpp:70
bool setPixelFormat(ofPixelFormat pixelFormat)
Set the requested ofPixelFormat.
Definition ofVideoGrabber.cpp:125
float getWidth() const
Get the video grabber's width.
Definition ofVideoGrabber.cpp:361
void setUseTexture(bool bUse)
Enable or disable internal ofTexture use.
Definition ofVideoGrabber.cpp:299
void setGrabber(std::shared_ptr< ofBaseVideoGrabber > newGrabber)
Definition ofVideoGrabber.cpp:65
void setAnchorPercent(float xPct, float yPct)
Set the anchor point the item is drawn around as a percentage.
Definition ofVideoGrabber.cpp:310
OF_DEPRECATED_MSG("Use getPixels() instead", ofPixels &getPixelsRef())
ofVideoGrabber()
Definition ofVideoGrabber.cpp:52
void resetAnchor()
Reset the anchor point to (0, 0).
Definition ofVideoGrabber.cpp:320
bool setup(int w, int h)
Set up the grabber with the requested width and height.
Definition ofVideoGrabber.h:25
OF_DEPRECATED_MSG("Use getTexture", ofTexture &getTextureReference())
bool initGrabber(int w, int h, bool bTexture))
Definition ofVideoGrabber.cpp:120
bool isInitialized() const
Determine if the video source is initialized.
Definition ofVideoGrabber.cpp:370
void close()
Close the video source.
Definition ofVideoGrabber.cpp:284
void unbind() const
Definition ofVideoGrabber.cpp:344
void setVerbose(bool bTalkToMe)
Set the video grabber's hardware verbosity level.
Definition ofVideoGrabber.cpp:163
void videoSettings()
Request a native GUI for video grabber settings.
Definition ofVideoGrabber.cpp:292
OF_DEPRECATED_MSG("Use getTexture", const ofTexture &getTextureReference() const)
void setAnchorPoint(float x, float y)
Set the anchor point the item is drawn around in pixels.
Definition ofVideoGrabber.cpp:315
const std::shared_ptr< GrabberType > getGrabber() const
Definition ofVideoGrabber.h:77
bool isFrameNew() const
Definition ofVideoGrabber.cpp:255
void update()
Update the object's state.
Definition ofVideoGrabber.cpp:263
OF_DEPRECATED_MSG("Use setup instead", bool initGrabber(int w, int h){return setup(w, h);}) OF_DEPRECATED_MSG("Use setup instead"
void bind() const
Definition ofVideoGrabber.cpp:336
ofPixelFormat getPixelFormat() const
Definition ofVideoGrabber.cpp:146
ofTexture & getTexture()
Definition ofVideoGrabber.cpp:206
float getHeight() const
Get the video grabber's height.
Definition ofVideoGrabber.cpp:352
std::shared_ptr< GrabberType > getGrabber()
Definition ofVideoGrabber.h:72
void setDeviceID(int _deviceID)
Set the video grabber's device ID.
Definition ofVideoGrabber.cpp:170
bool isUsingTexture() const
Definition ofVideoGrabber.cpp:304
void setDesiredFrameRate(int framerate)
Set the video grabber's desired frame rate.
Definition ofVideoGrabber.cpp:178
std::vector< ofTexture > & getTexturePlanes()
Definition ofVideoGrabber.cpp:236
#define OF_DEPRECATED_MSG(message,...)
Definition ofConstants.h:78
ofPixelFormat
Used to represent the available pixel formats.
Definition ofPixels.h:68
ofPixels_< float > ofFloatPixels
Definition ofVideoGrabber.h:9
ofPixels_< unsigned char > ofPixels
Definition ofVideoGrabber.h:8
ofPixels_< unsigned short > ofShortPixels
Definition ofVideoGrabber.h:10
ofPixels & ofPixelsRef
Definition ofVideoGrabber.h:11