00001 /* 00002 * This file is part of ALVAR, A Library for Virtual and Augmented Reality. 00003 * 00004 * Copyright 2007-2012 VTT Technical Research Centre of Finland 00005 * 00006 * Contact: VTT Augmented Reality Team <alvar.info@vtt.fi> 00007 * <http://www.vtt.fi/multimedia/alvar.html> 00008 * 00009 * ALVAR is free software; you can redistribute it and/or modify it under the 00010 * terms of the GNU Lesser General Public License as published by the Free 00011 * Software Foundation; either version 2.1 of the License, or (at your option) 00012 * any later version. 00013 * 00014 * This library is distributed in the hope that it will be useful, but WITHOUT 00015 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 00016 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License 00017 * for more details. 00018 * 00019 * You should have received a copy of the GNU Lesser General Public License 00020 * along with ALVAR; if not, see 00021 * <http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html>. 00022 */ 00023 00024 #ifndef CAPTUREPLUGINDSCAPTURE_H 00025 #define CAPTUREPLUGINDSCAPTURE_H 00026 00036 #ifdef WIN32 00037 #ifdef ALVAR_Capture_Plugin_DSCapture_BUILD 00038 #define ALVAR_CAPTURE_PLUGIN_DSCAPTURE_EXPORT __declspec(dllexport) 00039 #else 00040 #define ALVAR_CAPTURE_PLUGIN_DSCAPTURE_EXPORT __declspec(dllimport) 00041 #endif 00042 #else 00043 #define ALVAR_CAPTURE_PLUGIN_DSCAPTURE_EXPORT 00044 #endif 00045 00046 #include "Capture.h" 00047 #include "CapturePlugin.h" 00048 00049 #include "dscapture.h" 00050 00051 namespace alvar { 00052 00056 namespace plugins { 00057 00064 class ALVAR_CAPTURE_PLUGIN_DSCAPTURE_EXPORT CaptureDSCapture 00065 : public alvar::Capture 00066 { 00067 class VideoSampler : public IVideoCallback { 00068 public: 00069 CaptureDSCapture *parent; 00070 VideoSampler(CaptureDSCapture *_parent) : parent(_parent) {} 00071 void OnVideoSample(BYTE* pBuffer, DWORD dwDataLen, REFERENCE_TIME t_start) { 00072 parent->OnVideoSample(pBuffer, dwDataLen, t_start); 00073 } 00074 bool operator=(const VideoSampler &vs) { return parent == vs.parent; } 00075 } sampler; 00076 friend class VideoSampler; 00077 00078 void OnVideoSample(BYTE* pBuffer, DWORD dwDataLen, REFERENCE_TIME t_start); 00079 00080 public: 00081 00087 CaptureDSCapture(const CaptureDevice captureDevice); 00091 ~CaptureDSCapture(); 00092 bool start(); 00093 void stop(); 00094 IplImage *captureImage(); 00095 bool showSettingsDialog(); 00096 std::string SerializeId(); 00097 bool Serialize(Serialization *serialization); 00098 00099 00100 private: 00101 CDSCapture *m_pDSCapture; 00102 int m_nBpp; 00103 int m_nVideo_x_res; 00104 int m_nVideo_y_res; 00105 BYTE *imgBuffer; 00106 BYTE *imgBufferForCallback; 00107 IplImage *mReturnFrame; 00108 CRITICAL_SECTION crit; 00109 unsigned int buffer_size; 00110 HANDLE next_event; 00111 }; 00112 00119 class ALVAR_CAPTURE_PLUGIN_DSCAPTURE_EXPORT CapturePluginDSCapture 00120 : public alvar::CapturePlugin 00121 { 00122 public: 00128 CapturePluginDSCapture(const std::string &captureType); 00132 ~CapturePluginDSCapture(); 00133 CaptureDeviceVector enumerateDevices(); 00134 Capture *createCapture(const CaptureDevice captureDevice); 00135 }; 00136 00137 extern "C" ALVAR_CAPTURE_PLUGIN_DSCAPTURE_EXPORT void registerPlugin(const std::string &captureType, alvar::CapturePlugin *&capturePlugin); 00138 00139 } // namespace plugins 00140 } // namespace alvar 00141 00142 #endif