mirror of
https://github.com/panda3d/panda3d.git
synced 2025-10-03 18:31:55 -04:00
Changes to get OpenCV webcam working
This commit is contained in:
parent
f808e0a03b
commit
9861d44f82
@ -52,11 +52,11 @@ protected:
|
|||||||
virtual void reconsider_dirty();
|
virtual void reconsider_dirty();
|
||||||
virtual void do_reload_ram_image();
|
virtual void do_reload_ram_image();
|
||||||
|
|
||||||
INLINE void consider_update();
|
virtual INLINE void consider_update();
|
||||||
INLINE void clear_current_frame();
|
INLINE void clear_current_frame();
|
||||||
virtual void update_frame(int frame)=0;
|
virtual void update_frame(int frame)=0;
|
||||||
|
|
||||||
private:
|
protected:
|
||||||
int _video_width;
|
int _video_width;
|
||||||
int _video_height;
|
int _video_height;
|
||||||
int _last_frame_update;
|
int _last_frame_update;
|
||||||
|
@ -64,3 +64,32 @@ VideoPage(const OpenCVTexture::VideoPage ©) :
|
|||||||
INLINE OpenCVTexture::VideoPage::
|
INLINE OpenCVTexture::VideoPage::
|
||||||
~VideoPage() {
|
~VideoPage() {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////
|
||||||
|
// Function: OpenCVTexture::consider_update
|
||||||
|
// Access: Protected
|
||||||
|
// Description: Calls update_frame() if the current frame has
|
||||||
|
// changed.
|
||||||
|
////////////////////////////////////////////////////////////////////
|
||||||
|
INLINE void OpenCVTexture::
|
||||||
|
consider_update() {
|
||||||
|
int this_frame = ClockObject::get_global_clock()->get_frame_count();
|
||||||
|
if (this_frame != _last_frame_update) {
|
||||||
|
int frame = get_frame();
|
||||||
|
if (_current_frame != frame) {
|
||||||
|
update_frame(frame);
|
||||||
|
_current_frame = frame;
|
||||||
|
} else {
|
||||||
|
// Loop through the pages to see if there's any camera stream to update.
|
||||||
|
int max_z = max(_z_size, (int)_pages.size());
|
||||||
|
for (int z = 0; z < max_z; ++z) {
|
||||||
|
VideoPage &page = _pages[z];
|
||||||
|
if (!page._color.is_from_file() || !page._alpha.is_from_file()) {
|
||||||
|
update_frame(frame, z);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
_last_frame_update = this_frame;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@ -224,9 +224,21 @@ make_texture() {
|
|||||||
////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////
|
||||||
void OpenCVTexture::
|
void OpenCVTexture::
|
||||||
update_frame(int frame) {
|
update_frame(int frame) {
|
||||||
grutil_cat.spam() << "OpenCVTexture::update_frame called\n";
|
|
||||||
int max_z = max(_z_size, (int)_pages.size());
|
int max_z = max(_z_size, (int)_pages.size());
|
||||||
for (int z = 0; z < max_z; ++z) {
|
for (int z = 0; z < max_z; ++z) {
|
||||||
|
update_frame(frame, z);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////
|
||||||
|
// Function: OpenCVTexture::update_frame
|
||||||
|
// Access: Protected, Virtual
|
||||||
|
// Description: This variant of update_frame updates the
|
||||||
|
// indicated page only.
|
||||||
|
////////////////////////////////////////////////////////////////////
|
||||||
|
void OpenCVTexture::
|
||||||
|
update_frame(int frame, int z) {
|
||||||
|
grutil_cat.spam() << "Updating OpenCVTexture page " << z << "\n";
|
||||||
VideoPage &page = _pages[z];
|
VideoPage &page = _pages[z];
|
||||||
if (page._color.is_valid() || page._alpha.is_valid()) {
|
if (page._color.is_valid() || page._alpha.is_valid()) {
|
||||||
modify_ram_image();
|
modify_ram_image();
|
||||||
@ -297,7 +309,6 @@ update_frame(int frame) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////
|
||||||
|
@ -46,10 +46,12 @@ public:
|
|||||||
static PT(Texture) make_texture();
|
static PT(Texture) make_texture();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
virtual INLINE void consider_update();
|
||||||
virtual PT(Texture) do_make_copy();
|
virtual PT(Texture) do_make_copy();
|
||||||
void do_assign(const OpenCVTexture ©);
|
void do_assign(const OpenCVTexture ©);
|
||||||
|
|
||||||
virtual void update_frame(int frame);
|
virtual void update_frame(int frame);
|
||||||
|
virtual void update_frame(int frame, int z);
|
||||||
|
|
||||||
virtual bool do_read_one(const Filename &fullpath, const Filename &alpha_fullpath,
|
virtual bool do_read_one(const Filename &fullpath, const Filename &alpha_fullpath,
|
||||||
int z, int n, int primary_file_num_channels, int alpha_file_channel,
|
int z, int n, int primary_file_num_channels, int alpha_file_channel,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user