Permalink
Browse files

remove ofxPS3 and using theo's videoInput library directly to handle …

…both common usb cameras and ps3 camera.

automatically change the param panel's layout according to different background mode.
  • Loading branch information...
vinjn committed Feb 11, 2012
1 parent d6ba04f commit 05c77330efe0d46caee2a55d016c9d56805e0607
View
@@ -1,3 +1,13 @@
+Version 0.6.4
+remove ofxPS3 and using theo's videoInput library directly to handle both common usb cameras and ps3 camera.
+automatically change the param panel's layout according to different background mode.
+
+Version 0.6.2
+make a MacOSX solution
+
+Version 0.6.1
+make a public release
+
Version 0.6
implement normal exit
upgrade OpenCV to 2.3.1
@@ -26,6 +26,7 @@ AppConfig::AppConfig():CLIENT("localhost")
delay_for_run= 0;
bg_mode = DIFF_BG;
+ n_diff_frames = 2;//normal diff mode, change according to frame-rate
paramFlipX = 0;
paramFlipY = 0;
@@ -35,8 +36,8 @@ AppConfig::AppConfig():CLIENT("localhost")
paramBlur1 = 35;
paramBlur2 = 1;
paramNoise = 0;
- paramMinArea = 40;
- paramMaxArea = 800;
+ paramMinArea = 1;
+ paramMaxArea = 50;
};
bool using_debug_file = true;
@@ -56,8 +57,8 @@ std::string AppConfig::parse_args(int argc, char** argv)
"{log| |false|write log to file}"
"{minim ||false|minim windows mode}"
"{finger||false|enable finger track}"
- "{hand||false|enable hand track}"
- "{a|aut|false|auto background mode}"
+// "{hand||false|enable hand track}"
+// "{a|aut|false|auto background mode}"
"{1| |0|the input source, could be camera_idx/picture}"
"{h|help|false|display this help text}"
};
@@ -82,7 +83,7 @@ std::string AppConfig::parse_args(int argc, char** argv)
minim_window = args.get<bool>("minim");
delay_for_run = args.get<int>("delay");
finger_track = args.get<bool>("finger");
- hand_track = args.get<bool>("hand");
+// hand_track = args.get<bool>("hand");
PORT = args.get<int>("port");
std::string input_src = args.get<std::string>("1");
@@ -41,6 +41,7 @@ struct AppConfig
int paramNoise;
int paramMinArea;
int paramMaxArea;
+ int n_diff_frames;
cv::Point2f corners[4];
};
View
@@ -80,6 +80,7 @@ namespace monitor_gui
namespace param_gui
{
cv::Ptr<IplImage> setting;
+ bool is_changing_layout = false;
CvButtons buttons;
const int _w = 55;//btn width
@@ -89,7 +90,7 @@ namespace param_gui
const int dh = _h+10;//btn+space
int h = 35;
- int negative_one = -1;
+ int minus_one = -1;
void* handle = NULL;
@@ -145,31 +146,52 @@ namespace param_gui
void on_realbg(int t)
{
- theConfig.bg_mode = REAL_BG;
+ if (theConfig.bg_mode != REAL_BG)
+ {
+ theConfig.bg_mode = REAL_BG;
+ show(true);
+ }
theApp.onRefreshBack();
}
void on_whitebg(int t)
{
- theConfig.bg_mode = WHITE_BG;
+ if (theConfig.bg_mode != WHITE_BG)
+ {
+ theConfig.bg_mode = WHITE_BG;
+ show(true);
+ }
theApp.onRefreshBack();
}
void on_diffbg(int t)
{
- theConfig.bg_mode = DIFF_BG;
+ if (theConfig.bg_mode != DIFF_BG)
+ {
+ theConfig.bg_mode = DIFF_BG;
+ show(true);
+ }
+
theApp.onRefreshBack();
}
void on_blackbg(int t)
{
- theConfig.bg_mode = BLACK_BG;
+ if (theConfig.bg_mode != BLACK_BG)
+ {
+ theConfig.bg_mode = BLACK_BG;
+ show(true);
+ }
theApp.onRefreshBack();
}
void on_kinectbg(int t)
{
- theConfig.bg_mode = KINECT_BG;
+ if (theConfig.bg_mode != KINECT_BG)
+ {
+ show(true);
+ theConfig.bg_mode = KINECT_BG;
+ }
theApp.onRefreshBack();
}
ButtonInfo btn_infs[]=
@@ -181,7 +203,9 @@ namespace param_gui
{ w+=dw, h, "hull", on_hull, &theConfig.hull_mode},
// { w+=dw, h, "gray", on_mode, &theConfig.gray_detect_mode},
// { w=13, h+=dh, "expo", on_expo, &theConfig.auto_explosure},
- { w+=dw, h, "dialog", on_dialog, &negative_one},
+#ifdef WIN32
+ { w+=dw, h, "dialog", on_dialog, &minus_one},
+#endif // WIN32
{ w=13, h+=dh, "now", on_realbg, NULL},
{ w+=dw, h, "white", on_whitebg, NULL},
{ w+=dw, h, "black", on_blackbg, NULL},
@@ -231,6 +255,9 @@ namespace param_gui
{
if (visible)
{
+ is_changing_layout = true;
+ cvDestroyWindow(PARAM_WINDOW);
+ is_changing_layout = false;
cvNamedWindow(PARAM_WINDOW);
cvResizeWindow(PARAM_WINDOW,400,480);
@@ -244,8 +271,20 @@ namespace param_gui
// backModel = new vBackGrayDiff();
// backModel = new vBackColorDiff();
// backModel = new vThreeFrameDiff();
- cvCreateTrackbar("Darkness",PARAM_WINDOW,&theConfig.paramDark,PARAM_DARK, NULL);
- cvCreateTrackbar("Brightness",PARAM_WINDOW,&theConfig.paramBright,PARAM_BRIGHT, NULL);
+ if (theConfig.bg_mode == WHITE_BG)
+ cvCreateTrackbar("Darkness",PARAM_WINDOW,&theConfig.paramDark,PARAM_DARK, NULL);
+ else if (theConfig.bg_mode == BLACK_BG)
+ cvCreateTrackbar("Brightness",PARAM_WINDOW,&theConfig.paramBright,PARAM_BRIGHT, NULL);
+ else if (theConfig.bg_mode == KINECT_BG)
+ {
+ cvCreateTrackbar("Far",PARAM_WINDOW,&theConfig.paramDark,PARAM_DARK, NULL);
+ cvCreateTrackbar("Near",PARAM_WINDOW,&theConfig.paramBright,PARAM_BRIGHT, NULL);
+ }
+ else
+ {
+ cvCreateTrackbar("Below",PARAM_WINDOW,&theConfig.paramDark,PARAM_DARK, NULL);
+ cvCreateTrackbar("Above",PARAM_WINDOW,&theConfig.paramBright,PARAM_BRIGHT, NULL);
+ }
}
else
{
View
@@ -9,7 +9,7 @@
#define PARAM_BLUR1 80
#define PARAM_BLUR2 20
#define PARAM_NOISE 3
-#define PARAM_MAXAREA 1000
+#define PARAM_MAXAREA 200
namespace monitor_gui
{
@@ -21,6 +21,7 @@ namespace param_gui
{
extern void* handle;
extern cv::Ptr<IplImage> setting;
+ extern bool is_changing_layout;
void update();
void show(bool visible);
void init();
View
@@ -13,35 +13,36 @@ int CamServer_WindowCallback(HWND hwnd, UINT uMsg, WPARAM wparam, LPARAM lparam,
{
if (uMsg == WM_DESTROY)
{
- if ((hwnd == (HWND)monitor_gui::handle && theApp.monitorVisible) || hwnd == (HWND)param_gui::handle)
+ if ((hwnd == (HWND)monitor_gui::handle && theApp.monitorVisible) || (hwnd == (HWND)param_gui::handle && !param_gui::is_changing_layout))
theApp.app_running = false;
}
return 0;
}
#endif
-VideoApp::VideoGrabThread::VideoGrabThread(VideoInput& input):MiniThread("video"),_input(input)
+VideoGrabThread::VideoGrabThread(VideoInput& input):MiniThread("grab"),_input(input)
{
fps = 0;
}
-bool VideoApp::VideoGrabThread::is_dirty()
+bool VideoGrabThread::is_dirty()
{
bool ret = _dirty;
_dirty = false;
return ret;
}
-void VideoApp::VideoGrabThread::threadedFunction()
+void VideoGrabThread::threadedFunction()
{
MiniTimer timer;
int frame_counter = 0;
int ms_counter = 0;
while(true)
{
- timer.resetStartTime();
if (!theApp.app_running)
return;
+
+ timer.resetStartTime();
_input.get_frame();
_dirty = true;
if (_input._InputType == _input.From_Video)
@@ -129,13 +130,13 @@ bool VideoApp::init(int argc, char** argv)
haar.scale = 2;
#endif
//grab related
- grab_thread->lock();//wait for VideoInput::init() returns
+// grab_thread->lock();//wait for VideoInput::init() returns
size = input._size;
channels = input._channel;
if (size.width < 400)
{
- size = size*2;//enlarge the size of camera with small resolution
+ size = size*2;//hack: enlarge the size of camera with small resolution
}
total = cvCreateImage(cv::Size(size.width*1.5, size.height*1.5), 8, 3);
cvSet(total, CV_RGB(122,122,122));
View
@@ -21,21 +21,21 @@
#define BEEP(freq, ms)
#endif
-struct VideoApp
+struct VideoGrabThread: public MiniThread
{
- struct VideoGrabThread: public MiniThread
- {
- int fps;
+ int fps;
- VideoInput& _input;
+ VideoInput& _input;
- VideoGrabThread(VideoInput& input);
- void threadedFunction();
- bool is_dirty();
- private:
- bool _dirty;
- };
+ VideoGrabThread(VideoInput& input);
+ void threadedFunction();
+ bool is_dirty();
+private:
+ bool _dirty;
+};
+struct VideoApp
+{
//thread
cv::Ptr<VideoGrabThread> grab_thread;
VideoInput input;
@@ -168,10 +168,8 @@ void VideoApp::run()
timer.profileFunction("vHighPass");
const int scale =HalfWidth*HalfHeight/PARAM_MAXAREA;
- int minArea = (theConfig.paramMinArea+1)*scale*0.1;
- int maxArea = theConfig.paramMaxArea*scale;// + HalfWidth*HalfHeight*0.1;
- if (maxArea < minArea*10)
- maxArea = minArea*10;
+ int minArea = (theConfig.paramMinArea)*scale/10;
+ int maxArea = minArea+(theConfig.paramMaxArea)*scale;
vFindBlobs(grayBuffer, blobs, minArea ,maxArea, theConfig.hull_mode == 1);
timer.profileFunction("vFindBlobs");
Oops, something went wrong.

0 comments on commit 05c7733

Please sign in to comment.