[mousetrap/ng] Added missing files
- From: Flavio Percoco <flaper src gnome org>
- To: svn-commits-list gnome org
- Cc:
- Subject: [mousetrap/ng] Added missing files
- Date: Sun, 3 Jan 2010 13:05:53 +0000 (UTC)
commit 60393f0ef3786d82aa5b1172b96e1b6959764565
Author: Flavio Percoco Premoli <flaper87 gmail com>
Date: Sun Jan 3 15:21:00 2010 +0100
Added missing files
src/mousetrap/ocvfw/.pydevproject | 7 +
.../org.eclipse.ltk.core.refactoring.prefs | 3 +
src/mousetrap/ocvfw/backends/OcvfwBase.cpp | 114 +++++++++++++++
src/mousetrap/ocvfw/include/MtpCamera.h | 42 ++++++
src/mousetrap/ocvfw/include/MtpCapture.h | 149 ++++++++++++++++++++
src/mousetrap/ocvfw/include/OcvfwBase.h | 92 ++++++++++++
src/mousetrap/ocvfw/setup.py | 28 ++++
7 files changed, 435 insertions(+), 0 deletions(-)
---
diff --git a/src/mousetrap/ocvfw/.pydevproject b/src/mousetrap/ocvfw/.pydevproject
new file mode 100644
index 0000000..aa248f7
--- /dev/null
+++ b/src/mousetrap/ocvfw/.pydevproject
@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<?eclipse-pydev version="1.0"?>
+
+<pydev_project>
+<pydev_property name="org.python.pydev.PYTHON_PROJECT_VERSION">python 2.6</pydev_property>
+<pydev_property name="org.python.pydev.PYTHON_PROJECT_INTERPRETER">Default</pydev_property>
+</pydev_project>
diff --git a/src/mousetrap/ocvfw/.settings/org.eclipse.ltk.core.refactoring.prefs b/src/mousetrap/ocvfw/.settings/org.eclipse.ltk.core.refactoring.prefs
new file mode 100644
index 0000000..0ccbe07
--- /dev/null
+++ b/src/mousetrap/ocvfw/.settings/org.eclipse.ltk.core.refactoring.prefs
@@ -0,0 +1,3 @@
+#Sat Oct 31 11:32:45 CET 2009
+eclipse.preferences.version=1
+org.eclipse.ltk.core.refactoring.enable.project.refactoring.history=false
diff --git a/src/mousetrap/ocvfw/backends/OcvfwBase.cpp b/src/mousetrap/ocvfw/backends/OcvfwBase.cpp
new file mode 100644
index 0000000..d27e4a3
--- /dev/null
+++ b/src/mousetrap/ocvfw/backends/OcvfwBase.cpp
@@ -0,0 +1,114 @@
+/**
+ * Ocvfw
+ *
+ * Copyright 2009 Flavio Percoco Premoli
+ * Copyright (C) 2009 Rohan Anil (rohan anil gmail com)
+ *
+ * This file is part of Ocvfw.
+ *
+ * Ocvfw is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License v2 as published
+ * by the Free Software Foundation.
+ *
+ * Ocvfw is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with Ocvfw. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+/**
+ * TODO: set
+ * TODO: lk_swap
+ * TODO: set_camera_idx
+ * TODO: start_camera
+ * TODO: query_image
+ * TODO: set_lkpoint
+ * TODO: clean_lkpoints
+ * TODO: show_lkpoints
+ * TODO: swap_lkpoints
+ */
+
+#include "cv.h"
+#include "highgui.h"
+#include "OcvfwBase.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
+
+
+
+OcvfwBase::OcvfwBase() {
+}
+
+void OcvfwBase::stopCamera()
+{
+ if(capture!=0)
+ cvReleaseCapture( &capture );
+}
+
+int OcvfwBase::startCamera(int idx)
+{
+ capture = cvCaptureFromCAM(idx);
+
+ if(capture==0)
+ return 0;
+ else
+ return 1;
+}
+
+IplImage *OcvfwBase::queryFrame()
+{
+ orginalFrame = cvQueryFrame( capture );
+ if (orginalFrame==NULL)
+ return 0;
+
+ frame = this->newImage( cvSize(IMAGE_WIDTH,IMAGE_HEIGHT), IPL_DEPTH_8U, orginalFrame->nChannels );
+ cvResize(orginalFrame,frame, CV_INTER_LINEAR);
+
+ if ( !frame )
+ return 0;
+
+ frame_copy = this->newImage( cvSize(frame->width,frame->height), IPL_DEPTH_8U, frame->nChannels );
+
+ if ( frame->origin == IPL_ORIGIN_TL )
+ cvCopy( frame, frame_copy, 0 );
+ else
+ cvFlip( frame, frame_copy, 0 );
+
+ cvReleaseImage(&frame);
+
+ return frame_copy;
+}
+
+IplImage *OcvfwBase::newImage(CvSize size, int depth, int channels) {
+ return cvCreateImage(size, depth, channels);
+}
+
+int OcvfwBase::waitKey(int num) {
+ return cvWaitKey(num);
+}
+
+int OcvfwBase::getHaarPoints(char haarclassifier) {
+ CvHaarClassifierCascade* cascade;
+
+ cascade = (CvHaarClassifierCascade*)cvLoad(haarclassifier, 0, 0, 0);
+
+ if (cascade) {
+
+ }
+}
+
diff --git a/src/mousetrap/ocvfw/include/MtpCamera.h b/src/mousetrap/ocvfw/include/MtpCamera.h
new file mode 100644
index 0000000..6dacbd6
--- /dev/null
+++ b/src/mousetrap/ocvfw/include/MtpCamera.h
@@ -0,0 +1,42 @@
+/**
+ * Ocvfw
+ *
+ * Copyright 2009 Flavio Percoco Premoli
+ * Copyright (C) 2009 Rohan Anil (rohan anil gmail com)
+ *
+ * This file is part of Ocvfw.
+ *
+ * Ocvfw is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License v2 as published
+ * by the Free Software Foundation.
+ *
+ * Ocvfw is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with Ocvfw. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+/** @file */
+
+#include "cv.h"
+#include "highgui.h"
+#include "OcvfwBase.h"
+
+#ifndef _INCL_GUARD_WEBCAM
+#define _INCL_GUARD_WEBCAM
+/**
+* OpenCV Webcam Class. This class wraps over the opencv Image Query Functions.
+*/
+class MtpCamera: public OcvfwBase
+{
+public:
+ /**
+ *The Constructor
+ *Currently does nothing
+ */
+ MtpCamera(void);
+};
+#endif
diff --git a/src/mousetrap/ocvfw/include/MtpCapture.h b/src/mousetrap/ocvfw/include/MtpCapture.h
new file mode 100644
index 0000000..b50492a
--- /dev/null
+++ b/src/mousetrap/ocvfw/include/MtpCapture.h
@@ -0,0 +1,149 @@
+/**
+ * Ocvfw
+ *
+ * Copyright 2009 Flavio Percoco Premoli
+ * Copyright (C) 2009 Rohan Anil (rohan anil gmail com)
+ *
+ * This file is part of Ocvfw.
+ *
+ * Ocvfw is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License v2 as published
+ * by the Free Software Foundation.
+ *
+ * Ocvfw is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with Ocvfw. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+/** @file */
+
+
+
+#include <stdio.h>
+#include <glibmm.h>
+
+
+#include "cv.h"
+#include "highgui.h"
+#include "MtpCamera.h"
+
+/**
+ * OpenCV Webcam Class. This class wraps over the opencv Image Query Functions.
+ */
+class MtpCapture
+{
+public:
+
+ /**
+ * FPS
+ */
+ int fps;
+
+ /**
+ * Whether it has to query images asynchronously
+ */
+ bool async;
+
+ /**
+ * The Constructor
+ * Currently does nothing
+ */
+ MtpCapture(void);
+
+ /**
+ * Used to init the camera and capture vars
+ *
+ * @param set_fps The how frequently should be called the sync method.
+ * @param set_async Whether to set or not the asynchronous calls.
+ * @param idx The Camera Index.
+ */
+ void init(int set_fps=100, bool set_async=false, int idx=0);
+
+ /**
+ * Resizes the image
+ *
+ * @param width The new image width
+ * @param height The new image height
+ * @param copy Whether to create a new image with the new size
+ * or replace the current one.
+ * @return the resized image.
+ *
+ */
+ IplImage *resize(int width, int height, bool copy=false);
+
+ /**
+ * Returns the image and allows users to change the
+ * current image pointer.
+ */
+ IplImage *image();
+
+ /**
+ * Synchronize the capture quering a new frame.
+ */
+ bool sync();
+
+ /**
+ * Starts/Stops the asynchronous calls to the sync method.
+ *
+ * @param set_fps The how frequently should be called the sync method.
+ * @param set_async Whether to set or not the asynchronous calls
+ */
+ void set_async(int set_fps=100, bool set_async=false);
+
+ /**
+ * Gets and Returns the required rectangle of the image.
+ *
+ * @param rect A CvRect object with the new rectangle params.
+ * @returns The pointer to the IplImage rectangle.
+ */
+ IplImage *rect(CvRect rect);
+
+ /**
+ * Changes the color of the current image frame.
+ *
+ * @param new_color The new color to set. (Use CV globals).
+ * @param copy Whether to copy the image or not.
+ *
+ * @returns The pointer to the converted image.
+ */
+ IplImage *color(int channel, int new_color, bool copy=false);
+
+ /**
+ * Flips the image
+ *
+ * @param flip What axis should be flipped.
+ * 0 horizontally
+ * 1 horizontal and vertically
+ * 2 vertically
+ *
+ */
+ void flip(int flip);
+
+private:
+ /**
+ *Opencv Capture Structure
+ */
+ IplImage* img;
+
+ /**
+ * Camera Object
+ */
+ MtpCamera webcam;
+
+
+ /**
+ * Timer Slot
+ */
+ sigc::slot<bool> syncSlot;
+
+ /**
+ * The timer
+ */
+ sigc::connection timer;
+
+};
+
diff --git a/src/mousetrap/ocvfw/include/OcvfwBase.h b/src/mousetrap/ocvfw/include/OcvfwBase.h
new file mode 100644
index 0000000..11138d8
--- /dev/null
+++ b/src/mousetrap/ocvfw/include/OcvfwBase.h
@@ -0,0 +1,92 @@
+/**
+ * Ocvfw
+ *
+ * Copyright 2009 Flavio Percoco Premoli
+ * Copyright (C) 2009 Rohan Anil (rohan anil gmail com)
+ *
+ * This file is part of Ocvfw.
+ *
+ * Ocvfw is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License v2 as published
+ * by the Free Software Foundation.
+ *
+ * Ocvfw is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with Ocvfw. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+/** @file */
+
+#include "cv.h"
+#include "highgui.h"
+
+#ifndef OCVFWBASE_H_
+#define OCVFWBASE_H_
+
+/**
+ * Base Framework class.
+ */
+class OcvfwBase
+{
+public:
+
+ /**
+ * The Constructor
+ * Currently does nothing
+ */
+ OcvfwBase(void);
+
+ /**
+ * OpenCV WaitKey call
+ */
+ int waitKey(int num);
+
+ /**
+ * Creates a new image. Currently just calls OpenCv CreateImage
+ *
+ * @param size The image size
+ * @param depth The image depth
+ * @param channels The number of channels.
+ *
+ * @return A pointer to the new image.
+ */
+ IplImage *newImage(CvSize size, int depth, int channels);
+
+
+ /**
+ *Query Image From Webcam
+ * result Image From the Webcam
+ */
+ IplImage *queryFrame();
+
+ /**
+ *Initialize Webcam for Querying Image
+ * result returns 1 for Sucess and 0 for Failure
+ */
+ int startCamera(int idx);
+
+ /**
+ *Deinitialize Webcam Structures
+ */
+ void stopCamera();
+
+
+private:
+ /**
+ *Opencv Capture Structure
+ */
+ CvCapture* capture;
+
+ /**
+ * The camera index.
+ */
+ int idx;
+
+
+};
+
+#endif /* OCVFWBASE_H_ */
diff --git a/src/mousetrap/ocvfw/setup.py b/src/mousetrap/ocvfw/setup.py
new file mode 100644
index 0000000..74e1112
--- /dev/null
+++ b/src/mousetrap/ocvfw/setup.py
@@ -0,0 +1,28 @@
+import os
+from distutils.core import setup
+from distutils.core import Extension
+
+os.environ['CC'] = 'g++ -shared -fpic'
+os.environ['CXX'] = 'g++ -shared -fpic'
+os.environ['CPP'] = 'g++ -shared -fpic'
+os.environ['LDSHARED'] = 'g++ -shared -fpic'
+
+extra_options = {'build': ['-shared', '-fpic']}
+
+module = Extension('capture',
+ libraries = ['cv', 'highgui', 'cxcore', 'cvaux', 'ml', 'gobject-2.0', 'gmodule-2.0', 'gthread-2.0', 'rt', 'xml2', 'glib-2.0', 'glibmm-2.4', 'sigc-2.0'],
+ include_dirs=['/usr/include/opencv',
+ '/usr/include/glib-2.0/',
+ '/usr/lib/glib-2.0/include/',
+ '/usr/include/glibmm-2.4/',
+ '/usr/lib/glibmm-2.4/include/',
+ '/usr/include/libxml2/',
+ '/usr/include/sigc++-2.0/',
+ '/usr/include/sigc++-2.0/sigc++/',
+ '/usr/lib/sigc++-2.0/include',
+ './include/'],
+ sources = ['backends/OcvfwBase.cpp','dev/MtpCamera.cpp', 'dev/MtpCapture.cpp', 'dev/PyMtpCapture.cpp'],)
+
+setup(name = 'capture',
+ version = '0.1',
+ ext_modules = [module])
\ No newline at end of file
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]