diff --git a/configuration.cc b/configuration.cc
index b19b476..0a3e948 100644
--- a/configuration.cc
+++ b/configuration.cc
@@ -44,6 +44,8 @@ Configuration::Configuration() {
web_height = -1;
web_width = -1;
web_imagerefresh = 250;
+
+ filter_ratio = 0.5;
};
Configuration::~Configuration() {
@@ -276,3 +278,38 @@ void Configuration::Help() {
printf (" ./miniwebcam -sslkey ./ssl-key.pem -sslcert ./ssl-cert.pem -websize 800x600\n");
}
+
+
+
+void Configuration::SetValue(std::string name, std::string value) {
+ if (name.compare("filter_ratio") == 0) {
+ filter_ratio = atof(value.c_str());
+ debug ("Filter Ration set to : %g", filter_ratio);
+ }
+};
+
+
+std::string Configuration::GetValues() {
+ JSONParse jp;
+ JSONElement je;
+
+ je.Clear();
+ jp.Clear();
+
+ JSONParse jpe;
+
+ //
+ jpe.Clear();
+ jpe.AddObject("name", "filter_ratio");
+ jpe.AddObject("value", filter_ratio);
+ jpe.AddObject("desc", "Ratio between new to old image (1.0 = new image)");
+
+ je.SetAddArray("variables", jpe.ToString());
+
+ //
+
+
+ jp.AddObject(je);
+ return jp.ToString();
+};
+
diff --git a/configuration.h b/configuration.h
index 7dc070f..38f84a6 100644
--- a/configuration.h
+++ b/configuration.h
@@ -47,12 +47,17 @@ public:
std::string vdev_dumpfile;
std::string vdev_dumppath;
+ float filter_ratio;
+
Configuration();
~Configuration();
int LoadArgs(int argc, char **argv);
int LoadFile(std::string fn);
+ void SetValue(std::string name, std::string value);
+ std::string GetValues();
+
int GetInitFlags() { return initflags; };
std::string GetFilename() { return filename; };
diff --git a/main.cc b/main.cc
index 1236689..9566f74 100644
--- a/main.cc
+++ b/main.cc
@@ -73,7 +73,7 @@ static void *thread_video(void *ignored_argument) {
}
Lock();
inputimage.CopyTo(¤timage, config.web_width, config.web_height);
- if (inputfloatfilter.AddScaledImage(&inputfloat, 0.6, 0.4) == 0)
+ if (inputfloatfilter.AddScaledImage(&inputfloat, config.filter_ratio) == 0)
inputfloat.CopyTo(&inputfloatfilter);
inputfloatfilter.CopyTo(¤timagefloat);
UnLock();
diff --git a/videoframe.cc b/videoframe.cc
index 72557b9..5e78be4 100644
--- a/videoframe.cc
+++ b/videoframe.cc
@@ -277,7 +277,7 @@ int VideoFrameFloat::CopyTo(VideoFrameFloat *dest) {
};
-int VideoFrameFloat::AddScaledImage(VideoFrameFloat *vf, float f1, float f2) {
+int VideoFrameFloat::AddScaledImage(VideoFrameFloat *vf, float ratio) {
float *sptr, *dptr;
int x, y;
@@ -285,7 +285,7 @@ int VideoFrameFloat::AddScaledImage(VideoFrameFloat *vf, float f1, float f2) {
for (dptr = memf, sptr = vf->GetPixBuf(), y = 0; y < height; y++)
for (x = 0; x < width*3; x++) {
- *dptr = f1 * (*dptr) + f2 * (*sptr);
+ *dptr = (1.0-ratio) * (*dptr) + ratio * (*sptr);
dptr++;
sptr++;
}
diff --git a/videoframe.h b/videoframe.h
index 2fdfd21..75fd4b6 100644
--- a/videoframe.h
+++ b/videoframe.h
@@ -49,7 +49,7 @@ class VideoFrameFloat {
int CopyTo(VideoFrame *dest);
int CopyTo(VideoFrameFloat *dest);
- int AddScaledImage(VideoFrameFloat *vf, float f1, float f2);
+ int AddScaledImage(VideoFrameFloat *vf, float ratio);
};
diff --git a/webserver.cc b/webserver.cc
index 02f0a02..f1e4a00 100644
--- a/webserver.cc
+++ b/webserver.cc
@@ -10,6 +10,9 @@ extern VideoDevice *vdev;
std::string API_Get_Ctrls();
std::string API_Set_Ctrl(std::string request);
+std::string API_Get_Values();
+std::string API_Set_Value(std::string request);
+
// InMemoryFile GenerateJpgFile(VideoFrame *vf);
InMemoryTar assets;
@@ -44,9 +47,20 @@ int WebCamServer::HandleRequest (WebRequestBuffer *requestbuffer, WebServerClien
if (webclient->SendResponseData(requestbuffer, API_Get_Ctrls(), "") != 1) return 0;
}
else if (request.find("/set/ctrl") != std::string::npos) {
- debug ("set controls");
+ debug ("set control");
if (webclient->SendResponseData(requestbuffer, API_Set_Ctrl(request), "") != 1) return 0;
}
+
+ else if (request.compare("/get/variables") == 0) {
+ debug ("get values");
+ if (webclient->SendResponseData(requestbuffer, API_Get_Values(), "") != 1) return 0;
+ }
+ else if (request.find("/set/var") != std::string::npos) {
+ debug ("set value");
+ if (webclient->SendResponseData(requestbuffer, API_Set_Value(request), "") != 1) return 0;
+ }
+
+
else if (isfile("www"+request)) {
if (webclient->SendResponseFile(requestbuffer, request, "") != 1) return 0;
}
@@ -102,14 +116,57 @@ std::string API_Set_Ctrl(std::string request) {
while ((t = strchr (t, '/'))) {
i++;
t++;
- if (i == 3) id = atol (t);
- if (i == 4) value = atoi (t);
+ printf ("%d %s\n", i, t);
+ if (i == 3) {
+ char *v = strchr (t, '=');
+ id = atol (t);
+ if (v == NULL) break;
+ value = atoi(++v);
+ debug ("id:%d value:%d", id, value);
+ vdev->SetDevCtrl(id, value);
+ break;
+ }
+ if (i > 4) break;
+ }
+
+
+ JSONParse jp;
+ jp.Clear();
+ return jp.ToString();
+}
+
+
+std::string API_Get_Values() {
+ return config.GetValues();
+}
+
+
+
+std::string API_Set_Value(std::string request) {
+ std::string name;
+ std::string value;
+ char *t = (char*) request.c_str();
+
+ int i = 0;
+ while ((t = strchr (t, '/'))) {
+ i++;
+ t++;
+ printf ("%d %s\n", i, t);
+ if (i == 3) {
+ char *v = strchr (t, '=');
+ if (v == NULL) break;
+ name = ((std::string) t).substr(0, (v-t));
+ value = (++v);
+ debug ("name:%s value:%s", name.c_str(), value.c_str());
+ config.SetValue(name, value);
+ break;
+ }
if (i > 4) break;
}
- vdev->SetDevCtrl(id, value);
JSONParse jp;
jp.Clear();
return jp.ToString();
-}
\ No newline at end of file
+}
+
diff --git a/www/default.css b/www/default.css
index 810e7ef..34b824d 100644
--- a/www/default.css
+++ b/www/default.css
@@ -2,3 +2,14 @@ body {
background-color: #444;
color: #BBB;
}
+
+table, th, td {
+ border: thin solid;
+ border-collapse: collapse;
+}
+
+.float {
+ float: left;
+ padding: 10px;
+ border: thin solid;
+}
diff --git a/www/index.html b/www/index.html
index 1ab02af..785a038 100644
--- a/www/index.html
+++ b/www/index.html
@@ -19,7 +19,14 @@
-