Permalink
Browse files

updating some progress

  • Loading branch information...
paulobarcelos committed Aug 7, 2011
1 parent 7c58eec commit 84c4588bf1d93f88c534149dffacbaad5abbcb22
@@ -0,0 +1 @@
+!.gitignore
@@ -122,6 +122,7 @@ if not exist "$(ProjectDir)\bin\data" mkdir "$(ProjectDir)\bin\data"
<ClCompile Include="..\..\ofxXmlSettings\libs\tinyxmlparser.cpp" />
<ClCompile Include="..\..\ofxXmlSettings\src\ofxXmlSettings.cpp" />
<ClCompile Include="..\src\ofxUeye.cpp" />
+ <ClCompile Include="..\src\ofxUeyeSettings.cpp" />
<ClCompile Include="src\main.cpp" />
<ClCompile Include="src\testApp.cpp" />
</ItemGroup>
@@ -25,6 +25,9 @@
<ClCompile Include="..\src\ofxUeye.cpp">
<Filter>addons\ofxUeye\src</Filter>
</ClCompile>
+ <ClCompile Include="..\src\ofxUeyeSettings.cpp">
+ <Filter>addons\ofxUeye\src</Filter>
+ </ClCompile>
</ItemGroup>
<ItemGroup>
<Filter Include="src">
View
@@ -2,7 +2,8 @@
//--------------------------------------------------------------
void testApp::setup(){
-
+ ofxXmlSettings test;
+ test.saveFile("cu");
ofSetVerticalSync(true);
ofAddListener(ueye.events.dimensionChanged, this, &testApp::ueyeDimensionChanged);
@@ -11,11 +12,12 @@ void testApp::setup(){
if(ueye.init())
{
+ //cout << (IS_BINNING_8X_VERTICAL | IS_BINNING_8X_HORIZONTAL) << endl;
// Get full area of the sensor, but skipping every second pixel
ueye.setBinning(IS_BINNING_4X_VERTICAL | IS_BINNING_4X_HORIZONTAL); // difference from subsamplimg? (apparently same bandwith but smoother image)
// smooth the bad pixels (apparently they come from factory with bad pixels...)
- ueye.enableBadPixelsCorrection();
+ //ueye.enableBadPixelsCorrection();
// Set AOI (always set AOI after binning, subsampling or scaler, otherwise you might not get the desired result)
ofRectangle fullHD;
@@ -27,24 +29,25 @@ void testApp::setup(){
//ueye.setAOINormalized(ofRectangle(0,0, 0.6, 0.6));
// Start grabbing pixels
- ueye.enableLive();
+ //ueye.enableLive();
+
+ settings.setup(&ueye);
}
- settings.init(&ueye);
+
}
//--------------------------------------------------------------
void testApp::ueyeDimensionChanged(ofxUeyeEventArgs &args){
// If we got here, bandwith has changed.
// Pixel Clock, FPS and Exposure should be adjusted.
- ueye.setPixelClock(ueye.getPixelClockMax());
+ //ueye.setPixelClock(ueye.getPixelClockMax());
//ueye.setFPS(ueye.getFPSMax());
- ueye.setFPS(60);
+ //ueye.setFPS(60);
tex.clear();
tex.allocate(ueye.getWidth(), ueye.getHeight(),GL_RGB);
}
//--------------------------------------------------------------
-bool once =false;
void testApp::update(){
ueye.update();
if(ueye.isReady() && ueye.isFrameNew())
@@ -62,7 +65,7 @@ void testApp::exit(){
}
//--------------------------------------------------------------
void testApp::keyPressed(int key){
- settings.processInput(key);
+ settings.keyPressed(key);
}
View
@@ -522,13 +522,15 @@ int ofxUeye::setFPS(double fps)
//////////////////////////////////////////////////////////////////////////////////
// setOptimalCameraTiming --------------------------------------------------------
//////////////////////////////////////////////////////////////////////////////////
-void ofxUeye::setOptimalCameraTiming()
+void ofxUeye::setOptimalCameraTiming(bool value)
{
- int pixelClock;
- double fps;
- int result = is_SetOptimalCameraTiming (m_hCam, IS_BEST_PCLK_RUN_ONCE, 10000, &pixelClock, &fps);
- is_SetPixelClock (m_hCam, pixelClock);
- is_SetFrameRate (m_hCam, fps, &fps);
+ if(value){
+ int pixelClock;
+ double fps;
+ int result = is_SetOptimalCameraTiming (m_hCam, IS_BEST_PCLK_RUN_ONCE, 10000, &pixelClock, &fps);
+ is_SetPixelClock (m_hCam, pixelClock);
+ is_SetFrameRate (m_hCam, fps, &fps);
+ }
}
//////////////////////////////////////////////////////////////////////////////////
// setOptimalCameraTiming --------------------------------------------------------
@@ -547,6 +549,7 @@ int ofxUeye::setColorCorrection(double factor){
//////////////////////////////////////////////////////////////////////////////////
int ofxUeye::enableBadPixelsCorrection()
{
+ _badPixelCorrection = true;
INT nRet;
nRet = is_HotPixel(m_hCam, IS_HOTPIXEL_ENABLE_SENSOR_CORRECTION, NULL, NULL);
if (nRet == IS_SUCCESS) return nRet;
@@ -560,6 +563,7 @@ int ofxUeye::enableBadPixelsCorrection()
//////////////////////////////////////////////////////////////////////////////////
int ofxUeye::disableBadPixelsCorrection()
{
+ _badPixelCorrection = false;
INT nRet = is_HotPixel(m_hCam, IS_HOTPIXEL_DISABLE_CORRECTION, NULL, NULL);
return nRet;
}
View
@@ -14,104 +14,132 @@ class ofxUeye{
ofxUeye();
~ofxUeye();
- // actions
+ // actions ---------------------------------------------------
void setVerbose(bool bTalkToMe);
void listDevices();
bool init(int id = 0); // 0: The first available camera will be initialized.
// 1-254: The camera with the specified camera ID will be initialized.
void close();
void update();
- // getters
+ // Flags ------------------------------------------------------
bool isReady();
bool isFrameNew();
+ // Pixels -----------------------------------------------------
unsigned char* getPixels();
+ // Sensor Dimensions ------------------------------------------
int getSensorHeight();
int getSensorWidth();
int getHeight();
int getWidth();
+
+ // Bandwidth -------------------------------------------------
+ inline int getBandwidth(){return is_GetUsedBandwidth(m_hCam);};
+
+ // Live ----------------------------------------------------
+ void setLive(bool value = true){if (value) enableLive(); else disableLive();};
+ bool isLive(){return bLive;};
+ void enableLive();
+ void disableLive();
+
+ // Binnig, subsampling ans scaler ------------------------
+ int setBinning(int mode);
+ int setSubSampling(int mode);
+ int setScaler(double factor);
+ // AOI -----------------------------------------------------
+ int setAOI(ofRectangle aoi);
ofRectangle getAOI();
+ int setAOINormalized(ofRectangle aoi);
ofRectangle getAOINormalized();
ofRectangle getAOIMax();
-
+
+
+ // Pixel Clock -------------------------------------------
+ int setPixelClock(int clock);
int getPixelClock();
int getPixelClockMin();
int getPixelClockMax();
int getPixelClockStep();
+ // FPS ---------------------------------------------------
+ int setFPS(double fps);
double getFPS();
double getFPSMin();
double getFPSMax();
double getFPSStep();
-
- inline int getBandwidth(){return is_GetUsedBandwidth(m_hCam);};
+ // Optimal Camera timing --------------------------------
+ void setOptimalCameraTiming(bool value = true);
+
+ // Bad Pixel Correction ---------------------------------
+ void setBadPixelsCorrection(bool value = true){if (value) enableBadPixelsCorrection(); else disableBadPixelsCorrection();};
+ bool isBadPixelsCorrection(){return _badPixelCorrection;};
+ int enableBadPixelsCorrection();
+ int disableBadPixelsCorrection();
+
+ // Exposure -----------------------------------------------
+ void setAutoExposureTime(bool value = true){if (value) enableAutoExposureTime(); else disableAutoExposureTime();};
inline bool isExposureTimeAuto(){double e ; is_SetAutoParameter (m_hCam, IS_GET_ENABLE_AUTO_SHUTTER, &e, 0); return (e == 1.0)?true:false;};
+ inline int enableAutoExposureTime(){double e = 1; return is_SetAutoParameter (m_hCam, IS_SET_ENABLE_AUTO_SHUTTER, &e, 0);};
+ inline int disableAutoExposureTime(){double e = 0; return is_SetAutoParameter (m_hCam, IS_SET_ENABLE_AUTO_SHUTTER, &e, 0);};
+
+ inline int setExposureTime(double exposure){return is_Exposure (m_hCam, IS_EXPOSURE_CMD_SET_EXPOSURE, (void*)&exposure, sizeof(exposure));};
inline double getExposureTime(){double exposure; is_Exposure (m_hCam, IS_EXPOSURE_CMD_GET_EXPOSURE, (void*)&exposure, sizeof(exposure)); return exposure;};
inline double getExposureTimeMin(){double min; is_Exposure (m_hCam, IS_EXPOSURE_CMD_GET_EXPOSURE_RANGE_MIN, (void*)&min, sizeof(min)); return min;};
inline double getExposureTimeMax(){double max; is_Exposure (m_hCam, IS_EXPOSURE_CMD_GET_EXPOSURE_RANGE_MAX, (void*)&max, sizeof(max)); return max;};
inline double getExposureTimeStep(){double step; is_Exposure (m_hCam, IS_EXPOSURE_CMD_GET_EXPOSURE_RANGE_INC, (void*)&step, sizeof(step)); return step;};
+ // White Balance -----------------------------------------
+ void setAutoWhiteBalance(bool value = true){if (value) enableAutoWhiteBalance(); else disableAutoWhiteBalance();};
+ int enableAutoWhiteBalance(){double e = WB_MODE_AUTO; return is_SetAutoParameter (m_hCam, IS_SET_ENABLE_AUTO_SENSOR_WHITEBALANCE, &e, 0);};
+ int disableAutoWhiteBalance(){double e = WB_MODE_DISABLE; return is_SetAutoParameter (m_hCam, IS_SET_ENABLE_AUTO_SENSOR_WHITEBALANCE, &e, 0);};
+
+ // Gain -------------------------------------------
+ void setAutoGain(bool value = true){if (value) enableAutoGain(); else disableAutoGain();};
inline bool isGainAuto(){double e ; is_SetAutoParameter (m_hCam, IS_GET_ENABLE_AUTO_GAIN, &e, 0); return (e == 1.0)?true:false;};
+ inline int enableAutoGain(){double e = 1; return is_SetAutoParameter (m_hCam, IS_SET_ENABLE_AUTO_GAIN, &e, 0);};
+ inline int disableAutoGain(){double e = 0; return is_SetAutoParameter (m_hCam, IS_SET_ENABLE_AUTO_GAIN, &e, 0);};
+
+ inline int setGainMaster(int gain){return is_SetHardwareGain(m_hCam, gain, IS_IGNORE_PARAMETER, IS_IGNORE_PARAMETER, IS_IGNORE_PARAMETER);};
inline int getGainMaster(){return is_SetHardwareGain (m_hCam, IS_GET_MASTER_GAIN, IS_IGNORE_PARAMETER, IS_IGNORE_PARAMETER, IS_IGNORE_PARAMETER);};
inline int getGainMasterMin(){return 0;};
inline int getGainMasterMax(){return 100;};
inline int getGainMasterStep(){return 1;};
-
+
+ inline int setGainRed(int gain){return is_SetHardwareGain (m_hCam, IS_IGNORE_PARAMETER, gain, IS_IGNORE_PARAMETER, IS_IGNORE_PARAMETER);};
inline int getGainRed(){return is_SetHardwareGain (m_hCam, IS_GET_RED_GAIN, IS_IGNORE_PARAMETER, IS_IGNORE_PARAMETER, IS_IGNORE_PARAMETER);};
inline int getGainRedMin(){return 0;};
inline int getGainRedMax(){return 100;};
inline int getGainRedStep(){return 1;};
+ inline int setGainGreen(int gain){return is_SetHardwareGain (m_hCam, IS_IGNORE_PARAMETER, IS_IGNORE_PARAMETER, gain, IS_IGNORE_PARAMETER);};
inline int getGainGreen(){return is_SetHardwareGain (m_hCam, IS_GET_GREEN_GAIN, IS_IGNORE_PARAMETER, IS_IGNORE_PARAMETER, IS_IGNORE_PARAMETER);};
inline int getGainGreenMin(){return 0;};
inline int getGainGreenMax(){return 100;};
inline int getGainGreenStep(){return 1;};
+ inline int setGainBlue(int gain){return is_SetHardwareGain (m_hCam, IS_IGNORE_PARAMETER, IS_IGNORE_PARAMETER, IS_IGNORE_PARAMETER, gain);};
inline int getGainBlue(){return is_SetHardwareGain (m_hCam, IS_GET_BLUE_GAIN, IS_IGNORE_PARAMETER, IS_IGNORE_PARAMETER, IS_IGNORE_PARAMETER);};
inline int getGainBlueMin(){return 0;};
inline int getGainBlueMax(){return 100;};
inline int getGainBlueStep(){return 1;};
+ // Color Saturation ---------------------------------
+ inline int setColorSaturation(int saturation){return is_SetSaturation (m_hCam, saturation,saturation);};
inline int getColorSaturation(){return is_SetSaturation(m_hCam, IS_GET_SATURATION_U,IS_GET_SATURATION_V);};
inline int getColorSaturationMin(){return 0;};
inline int getColorSaturationMax(){return 200;};
inline int getColorSaturationStep(){return 1;};
+ // Color Corection ---------------------------------
+ int setColorCorrection(double factor);
inline double getColorCorrection(){return _colorCorrection;};
inline double getColorCorrectionMin(){return 0;};
inline double getColorCorrectionMax(){return 1.0;};
inline double getColorCorrectionStep(){return 0.1;};
-
- // setters
- void enableLive();
- void disableLive();
- int enableBadPixelsCorrection();
- int disableBadPixelsCorrection();
- int enableAutoGain(){double e = 1; return is_SetAutoParameter (m_hCam, IS_SET_ENABLE_AUTO_GAIN, &e, 0);};
- int disableAutoGain(){double e = 0; return is_SetAutoParameter (m_hCam, IS_SET_ENABLE_AUTO_GAIN, &e, 0);};
- int enableAutoExposureTime(){double e = 1; return is_SetAutoParameter (m_hCam, IS_SET_ENABLE_AUTO_SHUTTER, &e, 0);};
- int disableAutoExposureTime(){double e = 0; return is_SetAutoParameter (m_hCam, IS_SET_ENABLE_AUTO_SHUTTER, &e, 0);};
- int enableAutoWhiteBalance(){double e = WB_MODE_AUTO; return is_SetAutoParameter (m_hCam, IS_SET_ENABLE_AUTO_SENSOR_WHITEBALANCE, &e, 0);};
- int disableAutoWhiteBalance(){double e = WB_MODE_DISABLE; return is_SetAutoParameter (m_hCam, IS_SET_ENABLE_AUTO_SENSOR_WHITEBALANCE, &e, 0);};
- int setBinning(int mode);
- int setSubSampling(int mode);
- int setScaler(double factor);
- int setAOINormalized(ofRectangle aoi);
- int setAOI(ofRectangle aoi);
- int setPixelClock(int clock);
- int setFPS(double fps);
- void setOptimalCameraTiming();
- inline int setExposureTime(double exposure){return is_Exposure (m_hCam, IS_EXPOSURE_CMD_SET_EXPOSURE, (void*)&exposure, sizeof(exposure));};
- inline int setGainMaster(int gain){return is_SetHardwareGain(m_hCam, gain, IS_IGNORE_PARAMETER, IS_IGNORE_PARAMETER, IS_IGNORE_PARAMETER);};
- inline int setGainRed(int gain){return is_SetHardwareGain (m_hCam, IS_IGNORE_PARAMETER, gain, IS_IGNORE_PARAMETER, IS_IGNORE_PARAMETER);};
- inline int setGainGreen(int gain){return is_SetHardwareGain (m_hCam, IS_IGNORE_PARAMETER, IS_IGNORE_PARAMETER, gain, IS_IGNORE_PARAMETER);};
- inline int setGainBlue(int gain){return is_SetHardwareGain (m_hCam, IS_IGNORE_PARAMETER, IS_IGNORE_PARAMETER, IS_IGNORE_PARAMETER, gain);};
- inline int setColorSaturation(int saturation){return is_SetSaturation (m_hCam, saturation,saturation);};
- int setColorCorrection(double factor);
// events
ofxUeyeEvents events;
@@ -144,6 +172,7 @@ class ofxUeye{
int _bitsPerPixel;
int _bytesPerPixel;
double _colorCorrection;
+ bool _badPixelCorrection;
// helpers
void calculateMaxAOI();
View
@@ -0,0 +1,95 @@
+/*
+ * ofxUeyeSettings.cpp
+ * ofxUeye
+ *
+ * Created by Paulo Barcelos on 7/26/11.
+ * Copyright 2011 paulobarcelos.com. All rights reserved.
+ *
+ */
+
+#include "ofxUeyeSettings.h"
+
+///////////////////////////////////////////////////////////////////////////////////
+// Constructor --------------------------------------------------------------------
+///////////////////////////////////////////////////////////////////////////////////
+ofxUeyeSettings::ofxUeyeSettings()
+{
+ ueye = NULL;
+}
+///////////////////////////////////////////////////////////////////////////////////
+// Destructor --------------------------------------------------------------------
+///////////////////////////////////////////////////////////////////////////////////
+ofxUeyeSettings::~ofxUeyeSettings()
+{
+ if(ueye != NULL) delete ueye;
+}
+///////////////////////////////////////////////////////////////////////////////////
+// setup --------------------------------------------------------------------------
+///////////////////////////////////////////////////////////////////////////////////
+void ofxUeyeSettings::setup(ofxUeye* ueye, int accessKey, string label)
+{
+ this->ueye = ueye;
+ settings.setup(accessKey, label);
+
+ /*settings.addMonitor(ueye, &ofxUeye::getBandwidth, "Bandwidth");
+ settings.addMonitor(ueye, &ofxUeye::getSensorWidth, "Sensor_Width");
+ settings.addMonitor(ueye, &ofxUeye::getSensorHeight, "Sensor_Height");
+ settings.addMonitor(ueye, &ofxUeye::getWidth, "AOI_Width");
+ settings.addMonitor(ueye, &ofxUeye::getHeight, "AOI_Height");*/
+
+ settings.addProperty(ueye, &ofxUeye::isLive,
+ ueye, &ofxUeye::setLive,
+ "Is_Live",
+ true);
+
+ settings.addProperty(ueye, &ofxUeye::getPixelClock,
+ ueye, &ofxUeye::setPixelClock,
+ "Pixel_Clock",
+ ueye, &ofxUeye::getPixelClockMin,
+ ueye, &ofxUeye::getPixelClockMax,
+ ueye, &ofxUeye::getPixelClockStep,
+ ueye->getPixelClockMax());
+
+ settings.addProperty(ueye, &ofxUeye::getFPS,
+ ueye, &ofxUeye::setFPS,
+ "FPS",
+ ueye, &ofxUeye::getFPSMin,
+ ueye, &ofxUeye::getFPSMax,
+ ueye, &ofxUeye::getFPSStep,
+ ueye->getFPSMax());
+
+ settings.addProperty(ueye, &ofxUeye::isBadPixelsCorrection,
+ ueye, &ofxUeye::setBadPixelsCorrection,
+ "Bad_pixels_correction",
+ true);
+
+ /*settings.addProperty(cm, &ColorsOfMovement::getNumStoredFrames,
+ cm, &ColorsOfMovement::setNumStoredFrames,
+ "Number_of_stored_frames",
+ cm, &ColorsOfMovement::getNumStoredFramesMin,
+ cm, &ColorsOfMovement::getNumStoredFramesMax,
+ cm, &ColorsOfMovement::getNumStoredFramesStep,
+ CM_DEFAULT_NUM_STORED_FRAMES);
+
+ settings.addProperty(cm, &ColorsOfMovement::getMode,
+ cm, &ColorsOfMovement::setMode,
+ "Mode",
+ cm, &ColorsOfMovement::getModeMin,
+ cm, &ColorsOfMovement::getModeMax,
+ cm, &ColorsOfMovement::getModeStep,
+ (int)CM_DEFAULT_MODE);*/
+}
+///////////////////////////////////////////////////////////////////////////////////
+// keyPressed ---------------------------------------------------------------------
+///////////////////////////////////////////////////////////////////////////////////
+void ofxUeyeSettings::keyPressed(int key)
+{
+ settings.keyPressed(key);
+}
+///////////////////////////////////////////////////////////////////////////////////
+// draw ---------------------------------------------------------------------------
+///////////////////////////////////////////////////////////////////////////////////
+void ofxUeyeSettings::draw(float x, float y)
+{
+ settings.draw(x, y);
+}
Oops, something went wrong.

0 comments on commit 84c4588

Please sign in to comment.