[mousetrap/ng] Created Camera Class
- From: Flavio Percoco <flaper src gnome org>
- To: svn-commits-list gnome org
- Cc:
- Subject: [mousetrap/ng] Created Camera Class
- Date: Sat, 31 Oct 2009 09:58:43 +0000 (UTC)
commit 7835f3ee90d539aa17d1f00ec1fc8b9a72c561d1
Author: Flavio Percoco Premoli <flaper87 gmail com>
Date: Sat Oct 31 12:14:02 2009 +0100
Created Camera Class
src/mousetrap/ocvfw/dev/Camera.cpp | 75 ++++++++++++++++++++++++++++++++++++
src/mousetrap/ocvfw/dev/Camera.h | 61 +++++++++++++++++++++++++++++
2 files changed, 136 insertions(+), 0 deletions(-)
---
diff --git a/src/mousetrap/ocvfw/dev/Camera.cpp b/src/mousetrap/ocvfw/dev/Camera.cpp
new file mode 100644
index 0000000..7bf7c6d
--- /dev/null
+++ b/src/mousetrap/ocvfw/dev/Camera.cpp
@@ -0,0 +1,75 @@
+/**
+ * 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/>.
+ */
+
+#include "cv.h"
+#include "highgui.h"
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <assert.h>
+#include <math.h>
+#include <float.h>
+#include <limits.h>
+#include <time.h>
+#include <ctype.h>
+#include "Camera.h"
+
+static IplImage * orginalFrame=0;
+IplImage * frame=0;
+IplImage * frame_copy=0;
+
+Camera::Camera()
+{
+
+}
+
+void Camera::stopCamera()
+{
+ if(capture!=0)
+ cvReleaseCapture( &capture );
+}
+int Camera::startCamera()
+{
+ capture =cvCaptureFromCAM(0);
+ if(capture==0)
+ return 0;
+ else
+ return 1;
+}
+
+IplImage *Camera::queryFrame()
+{
+ orginalFrame = cvQueryFrame( capture );
+ if (orginalFrame==NULL) return 0;
+ frame = cvCreateImage( cvSize(IMAGE_WIDTH,IMAGE_HEIGHT),IPL_DEPTH_8U, orginalFrame->nChannels );
+ cvResize(orginalFrame,frame, CV_INTER_LINEAR);
+ if ( !frame )
+ return 0;
+
+ frame_copy = cvCreateImage( 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;
+}
diff --git a/src/mousetrap/ocvfw/dev/Camera.h b/src/mousetrap/ocvfw/dev/Camera.h
new file mode 100644
index 0000000..4d5a17f
--- /dev/null
+++ b/src/mousetrap/ocvfw/dev/Camera.h
@@ -0,0 +1,61 @@
+/**
+ * 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 _INCL_GUARD_WEBCAM
+#define _INCL_GUARD_WEBCAM
+/**
+* OpenCV Webcam Class. This class wraps over the opencv Image Query Functions.
+*/
+class opencvWebcam
+{
+public:
+ /**
+ *The Constructor
+ *Currently does nothing
+ */
+ Camera(void);
+ /**
+ *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();
+ /**
+ *Deinitialize Webcam Structures
+ */
+ void stopCamera();
+
+private:
+ /**
+ *Opencv Capture Structure
+ */
+ CvCapture* capture;
+
+};
+#endif
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]