mirror of
https://github.com/panda3d/panda3d.git
synced 2025-10-01 09:23:03 -04:00
Move OpenCVTexture, ARToolKit and WebcamVideo to a new "vision" module
This commit is contained in:
parent
340aafea67
commit
7036d75501
@ -1,7 +1,7 @@
|
||||
#define OTHER_LIBS interrogatedb:c dconfig:c dtoolconfig:m \
|
||||
dtoolutil:c dtoolbase:c dtool:m prc:c
|
||||
|
||||
#define USE_PACKAGES opencv ffmpeg artoolkit
|
||||
#define USE_PACKAGES ffmpeg
|
||||
|
||||
#begin lib_target
|
||||
#define TARGET grutil
|
||||
@ -13,7 +13,6 @@
|
||||
#define SOURCES \
|
||||
pipeOcclusionCullTraverser.I pipeOcclusionCullTraverser.h \
|
||||
cardMaker.I cardMaker.h \
|
||||
arToolKit.I arToolKit.h \
|
||||
config_grutil.h \
|
||||
ffmpegTexture.I ffmpegTexture.h \
|
||||
movieTexture.I movieTexture.h \
|
||||
@ -26,12 +25,10 @@
|
||||
lineSegs.I lineSegs.h \
|
||||
multitexReducer.I multitexReducer.h multitexReducer.cxx \
|
||||
nodeVertexTransform.I nodeVertexTransform.h \
|
||||
openCVTexture.I openCVTexture.h \
|
||||
rigidBodyCombiner.I rigidBodyCombiner.h
|
||||
|
||||
#define INCLUDED_SOURCES \
|
||||
cardMaker.cxx \
|
||||
arToolKit.cxx \
|
||||
ffmpegTexture.cxx \
|
||||
movieTexture.cxx \
|
||||
fisheyeMaker.cxx \
|
||||
@ -41,15 +38,13 @@
|
||||
geoMipTerrain.cxx \
|
||||
sceneGraphAnalyzerMeter.cxx \
|
||||
heightfieldTesselator.cxx \
|
||||
nodeVertexTransform.cxx \
|
||||
openCVTexture.cxx \
|
||||
nodeVertexTransform.cxx \
|
||||
pipeOcclusionCullTraverser.cxx \
|
||||
lineSegs.cxx \
|
||||
rigidBodyCombiner.cxx
|
||||
|
||||
#define INSTALL_HEADERS \
|
||||
cardMaker.I cardMaker.h \
|
||||
arToolKit.I arToolKit.h \
|
||||
ffmpegTexture.I ffmpegTexture.h \
|
||||
movieTexture.I movieTexture.h \
|
||||
fisheyeMaker.I fisheyeMaker.h \
|
||||
@ -61,7 +56,6 @@
|
||||
lineSegs.I lineSegs.h \
|
||||
multitexReducer.I multitexReducer.h \
|
||||
nodeVertexTransform.I nodeVertexTransform.h \
|
||||
openCVTexture.I openCVTexture.h \
|
||||
rigidBodyCombiner.I rigidBodyCombiner.h
|
||||
|
||||
#define IGATESCAN all
|
||||
|
@ -17,7 +17,6 @@
|
||||
#include "sceneGraphAnalyzerMeter.h"
|
||||
#include "meshDrawer.h"
|
||||
#include "geoMipTerrain.h"
|
||||
#include "openCVTexture.h"
|
||||
#include "ffmpegTexture.h"
|
||||
#include "movieTexture.h"
|
||||
#include "pandaSystem.h"
|
||||
@ -98,34 +97,20 @@ init_libgrutil() {
|
||||
MovieTexture::init_type();
|
||||
MovieTexture::register_with_read_factory();
|
||||
#endif // HAVE_AUDIO
|
||||
#ifdef HAVE_OPENCV
|
||||
OpenCVTexture::init_type();
|
||||
OpenCVTexture::register_with_read_factory();
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_FFMPEG
|
||||
av_register_all();
|
||||
FFMpegTexture::init_type();
|
||||
FFMpegTexture::register_with_read_factory();
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_OPENCV
|
||||
PandaSystem *ps = PandaSystem::get_global_ptr();
|
||||
ps->add_system("OpenCV");
|
||||
#endif
|
||||
|
||||
#if defined(HAVE_FFMPEG)
|
||||
TexturePool *ts = TexturePool::get_global_ptr();
|
||||
if (use_movietexture) {
|
||||
#if defined(HAVE_FFMPEG)
|
||||
ts->register_texture_type(MovieTexture::make_texture, "avi mov mpg wmv asf flv nut ogm");
|
||||
#elif defined(HAVE_OPENCV)
|
||||
ts->register_texture_type(OpenCVTexture::make_texture, "avi");
|
||||
#endif
|
||||
} else {
|
||||
#if defined(HAVE_FFMPEG)
|
||||
ts->register_texture_type(FFMpegTexture::make_texture, "avi mov mpg wmv asf flv nut ogm");
|
||||
#elif defined(HAVE_OPENCV)
|
||||
ts->register_texture_type(OpenCVTexture::make_texture, "avi");
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
|
@ -1,5 +1,4 @@
|
||||
#include "cardMaker.cxx"
|
||||
#include "arToolKit.cxx"
|
||||
#include "heightfieldTesselator.cxx"
|
||||
#include "geoMipTerrain.cxx"
|
||||
#include "config_grutil.cxx"
|
||||
|
@ -1,4 +1,3 @@
|
||||
#include "openCVTexture.cxx"
|
||||
#include "ffmpegTexture.cxx"
|
||||
#include "movieTexture.cxx"
|
||||
#include "nodeVertexTransform.cxx"
|
||||
|
@ -25,7 +25,6 @@
|
||||
ffmpegVirtualFile.h ffmpegVirtualFile.I \
|
||||
userDataAudio.h userDataAudio.I \
|
||||
userDataAudioCursor.h userDataAudioCursor.I \
|
||||
webcamVideo.h webcamVideo.I \
|
||||
microphoneAudio.h microphoneAudio.I \
|
||||
config_movies.h
|
||||
|
||||
@ -43,8 +42,6 @@
|
||||
ffmpegVirtualFile.cxx \
|
||||
userDataAudio.cxx \
|
||||
userDataAudioCursor.cxx \
|
||||
webcamVideo.cxx \
|
||||
webcamVideoDS.cxx \
|
||||
microphoneAudio.cxx \
|
||||
microphoneAudioDS.cxx \
|
||||
config_movies.cxx
|
||||
@ -61,7 +58,6 @@
|
||||
ffmpegAudio.h ffmpegAudio.I \
|
||||
ffmpegAudioCursor.h ffmpegAudioCursor.I \
|
||||
ffmpegVirtualFile.h ffmpegVirtualFile.I \
|
||||
webcamVideo.h webcamVideo.I \
|
||||
microphoneAudio.h microphoneAudio.I \
|
||||
config_movies.h
|
||||
|
||||
|
@ -14,7 +14,6 @@
|
||||
|
||||
#include "config_movies.h"
|
||||
#include "dconfig.h"
|
||||
#include "webcamVideo.h"
|
||||
|
||||
#ifdef HAVE_FFMPEG
|
||||
extern "C" {
|
||||
@ -53,7 +52,6 @@ init_libmovies() {
|
||||
InkblotVideoCursor::init_type();
|
||||
UserDataAudio::init_type();
|
||||
UserDataAudioCursor::init_type();
|
||||
WebcamVideo::init_type();
|
||||
MicrophoneAudio::init_type();
|
||||
#ifdef HAVE_FFMPEG
|
||||
FfmpegVideo::init_type();
|
||||
|
@ -18,9 +18,6 @@
|
||||
#include "userDataAudio.cxx"
|
||||
#include "userDataAudioCursor.cxx"
|
||||
|
||||
#include "webcamVideo.cxx"
|
||||
#include "webcamVideoDS.cxx"
|
||||
|
||||
#include "microphoneAudio.cxx"
|
||||
#include "microphoneAudioDS.cxx"
|
||||
|
||||
|
34
panda/src/vision/Sources.pp
Normal file
34
panda/src/vision/Sources.pp
Normal file
@ -0,0 +1,34 @@
|
||||
#define OTHER_LIBS interrogatedb:c dconfig:c dtoolconfig:m \
|
||||
dtoolutil:c dtoolbase:c dtool:m prc:c movies:m
|
||||
|
||||
#define USE_PACKAGES opencv artoolkit
|
||||
|
||||
#begin lib_target
|
||||
#define TARGET vision
|
||||
#define LOCAL_LIBS \
|
||||
display text pgraph gobj linmath putil movies audio
|
||||
|
||||
#define COMBINED_SOURCES $[TARGET]_composite1.cxx
|
||||
|
||||
#define SOURCES \
|
||||
arToolKit.I arToolKit.h \
|
||||
config_vision.h \
|
||||
openCVTexture.I openCVTexture.h \
|
||||
webcamVideo.h webcamVideo.I
|
||||
|
||||
#define INCLUDED_SOURCES \
|
||||
arToolKit.cxx \
|
||||
config_vision.cxx \
|
||||
openCVTexture.cxx \
|
||||
webcamVideo.cxx \
|
||||
webcamVideoDS.cxx
|
||||
|
||||
#define INSTALL_HEADERS \
|
||||
arToolKit.I arToolKit.h \
|
||||
openCVTexture.I openCVTexture.h \
|
||||
webcamVideo.h webcamVideo.I
|
||||
|
||||
#define IGATESCAN all
|
||||
|
||||
#end lib_target
|
||||
|
@ -21,7 +21,7 @@
|
||||
#include "perspectiveLens.h"
|
||||
#include "lvecBase3.h"
|
||||
#include "compose_matrix.h"
|
||||
#include "config_grutil.h"
|
||||
#include "config_vision.h"
|
||||
extern "C" {
|
||||
#include "AR/ar.h"
|
||||
};
|
||||
@ -123,7 +123,7 @@ make(NodePath camera, const Filename ¶mfile, double marker_size) {
|
||||
AR_DEFAULT_PIXEL_FORMAT != AR_PIXEL_FORMAT_RGBA &&
|
||||
AR_DEFAULT_PIXEL_FORMAT != AR_PIXEL_FORMAT_RGB &&
|
||||
AR_DEFAULT_PIXEL_FORMAT != AR_PIXEL_FORMAT_BGR) {
|
||||
grutil_cat.error() <<
|
||||
vision_cat.error() <<
|
||||
"The copy of ARToolKit that you are using is not compiled "
|
||||
"for RGB, BGR, RGBA or ARGB input. Panda3D cannot use "
|
||||
"this copy of ARToolKit. Please modify the ARToolKit's "
|
||||
@ -132,25 +132,25 @@ make(NodePath camera, const Filename ¶mfile, double marker_size) {
|
||||
}
|
||||
|
||||
if (camera.is_empty()) {
|
||||
grutil_cat.error() << "ARToolKit: invalid camera nodepath\n";
|
||||
vision_cat.error() << "ARToolKit: invalid camera nodepath\n";
|
||||
return 0;
|
||||
}
|
||||
PandaNode *node = camera.node();
|
||||
if ((node == 0) || (node->get_type() != Camera::get_class_type())) {
|
||||
grutil_cat.error() << "ARToolKit: invalid camera nodepath\n";
|
||||
vision_cat.error() << "ARToolKit: invalid camera nodepath\n";
|
||||
return 0;
|
||||
}
|
||||
Camera *cam = DCAST(Camera, node);
|
||||
Lens *lens = cam->get_lens();
|
||||
if (lens->get_type() != PerspectiveLens::get_class_type()) {
|
||||
grutil_cat.error() << "ARToolKit: supplied camera node must be perspective.\n";
|
||||
vision_cat.error() << "ARToolKit: supplied camera node must be perspective.\n";
|
||||
return 0;
|
||||
}
|
||||
|
||||
ARParam wparam;
|
||||
string fn = paramfile.to_os_specific();
|
||||
if( arParamLoad(fn.c_str(), 1, &wparam) < 0 ) {
|
||||
grutil_cat.error() << "Cannot load ARToolKit camera config\n";
|
||||
vision_cat.error() << "Cannot load ARToolKit camera config\n";
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -221,7 +221,7 @@ get_pattern(const Filename &filename) {
|
||||
string fn = filename.to_os_specific();
|
||||
int id = arLoadPatt(fn.c_str());
|
||||
if (id < 0) {
|
||||
grutil_cat.error() << "Could not load AR ToolKit Pattern: " << fn << "\n";
|
||||
vision_cat.error() << "Could not load AR ToolKit Pattern: " << fn << "\n";
|
||||
return -1;
|
||||
}
|
||||
arDeactivatePatt(id);
|
||||
@ -275,7 +275,7 @@ analyze(Texture *tex, bool do_flip_texture) {
|
||||
nassertv(tex->get_texture_type() == Texture::TT_2d_texture);
|
||||
|
||||
if (tex->get_num_components() != 3 && tex->get_num_components() != 4) {
|
||||
grutil_cat.error() << "ARToolKit can only analyze RGB and RGBA textures.\n";
|
||||
vision_cat.error() << "ARToolKit can only analyze RGB and RGBA textures.\n";
|
||||
return;
|
||||
}
|
||||
|
||||
@ -381,7 +381,7 @@ analyze(Texture *tex, bool do_flip_texture) {
|
||||
int marker_num;
|
||||
|
||||
if (arDetectMarker(data, _threshold * 256, &marker_info, &marker_num) < 0) {
|
||||
grutil_cat.error() << "ARToolKit detection error.\n";
|
||||
vision_cat.error() << "ARToolKit detection error.\n";
|
||||
delete data;
|
||||
return;
|
||||
}
|
||||
@ -423,7 +423,7 @@ analyze(Texture *tex, bool do_flip_texture) {
|
||||
decompose_matrix(mat, scale, shear, hpr, pos);
|
||||
|
||||
if (np.get_parent().is_empty()) {
|
||||
grutil_cat.error() << "NodePath must have a parent.\n";
|
||||
vision_cat.error() << "NodePath must have a parent.\n";
|
||||
} else {
|
||||
np.set_pos_hpr(_camera, pos, hpr);
|
||||
}
|
@ -40,7 +40,7 @@
|
||||
// This class is a wrapper around the ARToolKit
|
||||
// library.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
class EXPCL_PANDA_GRUTIL ARToolKit {
|
||||
class EXPCL_VISION ARToolKit {
|
||||
|
||||
PUBLISHED:
|
||||
static ARToolKit *make(NodePath camera, const Filename ¶mfile, double markersize);
|
61
panda/src/vision/config_vision.cxx
Normal file
61
panda/src/vision/config_vision.cxx
Normal file
@ -0,0 +1,61 @@
|
||||
// Filename: config_vision.cxx
|
||||
// Created by: pro-rsoft (07Nov09)
|
||||
//
|
||||
////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// PANDA 3D SOFTWARE
|
||||
// Copyright (c) Carnegie Mellon University. All rights reserved.
|
||||
//
|
||||
// All use of this software is subject to the terms of the revised BSD
|
||||
// license. You should have received a copy of this license along
|
||||
// with this source code in a file named "LICENSE."
|
||||
//
|
||||
////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include "config_vision.h"
|
||||
#include "openCVTexture.h"
|
||||
#include "webcamVideo.h"
|
||||
|
||||
#include "pandaSystem.h"
|
||||
#include "texturePool.h"
|
||||
#include "dconfig.h"
|
||||
|
||||
Configure(config_vision);
|
||||
NotifyCategoryDef(vision, "");
|
||||
|
||||
ConfigureFn(config_vision) {
|
||||
init_libvision();
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: init_libvision
|
||||
// Description: Initializes the library. This must be called at
|
||||
// least once before any of the functions or classes in
|
||||
// this library can be used. Normally it will be
|
||||
// called by the static initializers and need not be
|
||||
// called explicitly, but special cases exist.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
void
|
||||
init_libvision() {
|
||||
static bool initialized = false;
|
||||
if (initialized) {
|
||||
return;
|
||||
}
|
||||
initialized = true;
|
||||
|
||||
WebcamVideo::init_type();
|
||||
|
||||
#ifdef HAVE_OPENCV
|
||||
OpenCVTexture::init_type();
|
||||
OpenCVTexture::register_with_read_factory();
|
||||
|
||||
PandaSystem *ps = PandaSystem::get_global_ptr();
|
||||
ps->add_system("OpenCV");
|
||||
|
||||
TexturePool *ts = TexturePool::get_global_ptr();
|
||||
#ifndef HAVE_FFMPEG
|
||||
ts->register_texture_type(OpenCVTexture::make_texture, "avi");
|
||||
#endif
|
||||
#endif
|
||||
}
|
||||
|
26
panda/src/vision/config_vision.h
Normal file
26
panda/src/vision/config_vision.h
Normal file
@ -0,0 +1,26 @@
|
||||
// Filename: config_vision.h
|
||||
// Created by: pro-rsoft (07Nov09)
|
||||
//
|
||||
////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// PANDA 3D SOFTWARE
|
||||
// Copyright (c) Carnegie Mellon University. All rights reserved.
|
||||
//
|
||||
// All use of this software is subject to the terms of the revised BSD
|
||||
// license. You should have received a copy of this license along
|
||||
// with this source code in a file named "LICENSE."
|
||||
//
|
||||
////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef CONFIG_VISION_H
|
||||
#define CONFIG_VISION_H
|
||||
|
||||
#include "pandabase.h"
|
||||
#include "notifyCategoryProxy.h"
|
||||
|
||||
NotifyCategoryDecl(vision, EXPCL_VISION, EXPTP_VISION);
|
||||
|
||||
extern EXPCL_VISION void init_libvision();
|
||||
|
||||
#endif
|
||||
|
@ -18,7 +18,7 @@
|
||||
#include "openCVTexture.h"
|
||||
#include "clockObject.h"
|
||||
#include "config_gobj.h"
|
||||
#include "config_grutil.h"
|
||||
#include "config_vision.h"
|
||||
#include "bamReader.h"
|
||||
#include "bamCacheRecord.h"
|
||||
|
||||
@ -156,8 +156,8 @@ do_reconsider_video_properties(const OpenCVTexture::VideoStream &stream,
|
||||
if (stream.is_from_file()) {
|
||||
frame_rate = cvGetCaptureProperty(stream._capture, CV_CAP_PROP_FPS);
|
||||
num_frames = (int)cvGetCaptureProperty(stream._capture, CV_CAP_PROP_FRAME_COUNT);
|
||||
if (grutil_cat.is_debug()) {
|
||||
grutil_cat.debug()
|
||||
if (vision_cat.is_debug()) {
|
||||
vision_cat.debug()
|
||||
<< "Loaded " << stream._filename << ", " << num_frames << " frames at "
|
||||
<< frame_rate << " fps\n";
|
||||
}
|
||||
@ -173,8 +173,8 @@ do_reconsider_video_properties(const OpenCVTexture::VideoStream &stream,
|
||||
y_size = up_to_power_2(height);
|
||||
}
|
||||
|
||||
if (grutil_cat.is_debug()) {
|
||||
grutil_cat.debug()
|
||||
if (vision_cat.is_debug()) {
|
||||
vision_cat.debug()
|
||||
<< "Video stream is " << width << " by " << height
|
||||
<< " pixels; fitting in texture " << x_size << " by "
|
||||
<< y_size << " texels.\n";
|
||||
@ -188,7 +188,7 @@ do_reconsider_video_properties(const OpenCVTexture::VideoStream &stream,
|
||||
if (_loaded_from_image &&
|
||||
(get_video_width() != width || get_video_height() != height ||
|
||||
get_num_frames() != num_frames || get_frame_rate() != frame_rate)) {
|
||||
grutil_cat.error()
|
||||
vision_cat.error()
|
||||
<< "Video properties have changed for texture " << get_name()
|
||||
<< " level " << z << ".\n";
|
||||
return false;
|
||||
@ -238,7 +238,7 @@ update_frame(int frame) {
|
||||
////////////////////////////////////////////////////////////////////
|
||||
void OpenCVTexture::
|
||||
update_frame(int frame, int z) {
|
||||
grutil_cat.spam() << "Updating OpenCVTexture page " << z << "\n";
|
||||
vision_cat.spam() << "Updating OpenCVTexture page " << z << "\n";
|
||||
VideoPage &page = _pages[z];
|
||||
if (page._color.is_valid() || page._alpha.is_valid()) {
|
||||
do_modify_ram_image();
|
||||
@ -332,13 +332,13 @@ do_read_one(const Filename &fullpath, const Filename &alpha_fullpath,
|
||||
|
||||
VideoPage &page = modify_page(z);
|
||||
if (!page._color.read(fullpath)) {
|
||||
grutil_cat.error()
|
||||
vision_cat.error()
|
||||
<< "OpenCV couldn't read " << fullpath << " as video.\n";
|
||||
return false;
|
||||
}
|
||||
if (!alpha_fullpath.empty()) {
|
||||
if (!page._alpha.read(alpha_fullpath)) {
|
||||
grutil_cat.error()
|
||||
vision_cat.error()
|
||||
<< "OpenCV couldn't read " << alpha_fullpath << " as video.\n";
|
||||
page._color.clear();
|
||||
return false;
|
@ -31,7 +31,7 @@
|
||||
// with its source taken from an .avi file or from a
|
||||
// camera input.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
class EXPCL_PANDA_GRUTIL OpenCVTexture : public VideoTexture {
|
||||
class EXPCL_VISION OpenCVTexture : public VideoTexture {
|
||||
PUBLISHED:
|
||||
OpenCVTexture(const string &name = string());
|
||||
protected:
|
6
panda/src/vision/vision_composite1.cxx
Normal file
6
panda/src/vision/vision_composite1.cxx
Normal file
@ -0,0 +1,6 @@
|
||||
#include "arToolKit.cxx"
|
||||
#include "config_vision.cxx"
|
||||
#include "openCVTexture.cxx"
|
||||
#include "webcamVideo.cxx"
|
||||
#include "webcamVideoDS.cxx"
|
||||
|
@ -22,7 +22,7 @@
|
||||
// Description : Allows you to open a webcam or other video capture
|
||||
// device as a video stream.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
class EXPCL_PANDA_MOVIES WebcamVideo : public MovieVideo {
|
||||
class EXPCL_VISION WebcamVideo : public MovieVideo {
|
||||
|
||||
PUBLISHED:
|
||||
virtual ~WebcamVideo();
|
Loading…
x
Reference in New Issue
Block a user