[mousetrap/ng] Changed bool with gboolean
- From: Flavio Percoco <flaper src gnome org>
- To: svn-commits-list gnome org
- Cc:
- Subject: [mousetrap/ng] Changed bool with gboolean
- Date: Sun, 1 Nov 2009 20:17:12 +0000 (UTC)
commit 45417d3674fb7b503542ffe35385fa7f114f0bdb
Author: Flavio Percoco Premoli <flaper87 gmail com>
Date: Sun Nov 1 22:32:29 2009 +0100
Changed bool with gboolean
src/mousetrap/ocvfw/dev/MtpCamera.cpp | 11 ++++++++++
src/mousetrap/ocvfw/dev/MtpCapture.cpp | 35 +++++++++++++++++++++----------
src/mousetrap/ocvfw/dev/MtpCapture.h | 25 ++++++++++++++++++++--
src/mousetrap/ocvfw/dev/setup.py | 11 ++++++++++
4 files changed, 68 insertions(+), 14 deletions(-)
---
diff --git a/src/mousetrap/ocvfw/dev/MtpCamera.cpp b/src/mousetrap/ocvfw/dev/MtpCamera.cpp
index c37e829..1529f93 100644
--- a/src/mousetrap/ocvfw/dev/MtpCamera.cpp
+++ b/src/mousetrap/ocvfw/dev/MtpCamera.cpp
@@ -31,10 +31,21 @@
#include <time.h>
#include <ctype.h>
+#include "MtpCamera.h"
+
static IplImage * orginalFrame=0;
IplImage * frame=0;
IplImage * frame_copy=0;
+/**
+ * Image Width of Webcam
+ */
+#define IMAGE_WIDTH 320
+/*
+ * Image Height of Webcam
+ */
+#define IMAGE_HEIGHT 240
+
MtpCamera::MtpCamera()
{
diff --git a/src/mousetrap/ocvfw/dev/MtpCapture.cpp b/src/mousetrap/ocvfw/dev/MtpCapture.cpp
index 48b21ad..15460ad 100644
--- a/src/mousetrap/ocvfw/dev/MtpCapture.cpp
+++ b/src/mousetrap/ocvfw/dev/MtpCapture.cpp
@@ -20,38 +20,51 @@
*/
+
#include "cv.h"
#include "highgui.h"
#include "MtpCamera.h"
+#include <stdio.h>
#include <glib.h>
#include "MtpCapture.h"
-int fps = 0;
-bool async = false;
-
MtpCapture::MtpCapture() {
- webcam.startCamera(0);
+
+}
+
+void MtpCapture::init(int set_fps, bool set_async, int idx) {
+ fps = set_fps;
+ async = set_async;
+ webcam.startCamera(idx);
}
-void MtpCapture::set_async(int set_fps=100, bool set_async=false) {
+void MtpCapture::set_async(int set_fps, bool set_async) {
fps = set_fps;
async = set_async;
if ( set_async == true)
- g_timeout_add(set_fps, sync, NULL);
+ g_timeout_add(set_fps, sync);
}
-bool MtpCapture::sync() {
+gboolean MtpCapture::sync() {
image = webcam.queryFrame();
if (!image)
- return async;
+ return TRUE;
- return async;
+ return TRUE;
}
-IplImage *MtpCapture::resize(int width, int height, bool copy=false) {
- return image;
+IplImage *MtpCapture::resize(int width, int height, bool copy) {
+ IplImage *tmp;
+
+ tmp = cvCreateImage(cvSize(width, height), 8, image->nChannels);
+ cvResize(image, tmp, CV_INTER_AREA);
+
+ if (!copy)
+ image = tmp;
+
+ return tmp;
}
diff --git a/src/mousetrap/ocvfw/dev/MtpCapture.h b/src/mousetrap/ocvfw/dev/MtpCapture.h
index bf4657c..5e23aa1 100644
--- a/src/mousetrap/ocvfw/dev/MtpCapture.h
+++ b/src/mousetrap/ocvfw/dev/MtpCapture.h
@@ -23,6 +23,9 @@
#include "cv.h"
#include "highgui.h"
+
+#include <glib.h>
+
#include "MtpCamera.h"
/**
@@ -31,13 +34,29 @@
class MtpCapture
{
public:
+
+ /**
+ * FPS
+ */
+ int fps;
+
/**
- *The Constructor
- *Currently does nothing
+ * Whether it has to query images asynchronously
+ */
+ bool async;
+
+ /**
+ * The Constructor
+ * Currently does nothing
*/
MtpCapture(void);
/**
+ * Used to init the camera and capture vars
+ */
+ void init(int set_fps=100, bool set_async=false, int idx=0);
+
+ /**
* Resizes the image
*/
IplImage *resize(int width, int height, bool copy=false);
@@ -45,7 +64,7 @@ public:
/**
* Synchronize the capture quering a new frame.
*/
- bool sync();
+ gboolean sync();
/**
* Starts/Stops the asynchronous calls to the sync method.
diff --git a/src/mousetrap/ocvfw/dev/setup.py b/src/mousetrap/ocvfw/dev/setup.py
new file mode 100644
index 0000000..c349f9c
--- /dev/null
+++ b/src/mousetrap/ocvfw/dev/setup.py
@@ -0,0 +1,11 @@
+from distutils.core import setup
+from distutils.core import Extension
+
+module2 = Extension('capture',
+ libraries = ['cv', 'highgui', 'cxcore', 'cvaux', 'ml', 'gstreamer-0.10', 'gobject-2.0', 'gmodule-2.0', 'gthread-2.0', 'rt', 'xml2', 'glib-2.0'],
+ include_dirs=['/usr/include/opencv', '/usr/include/gstreamer-0.10/', '/usr/include/glib-2.0/', '/usr/lib/glib-2.0/include/', '/usr/include/libxml2/'],
+ sources = ['MtpCamera.cpp', 'MtpCapture.cpp', 'PyMtpCapture.cpp'])
+
+setup(name = 'capture',
+ version = '0.1',
+ ext_modules = [module2])
\ No newline at end of file
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]