00001 /* 00002 * Camera.cc 00003 * Copyright (C) James Goppert 2009 <jgoppert@users.sourceforge.net> 00004 * 00005 * Camera.cc is free software: you can redistribute it and/or modify it 00006 * under the terms of the GNU General Public License as published by the 00007 * Free Software Foundation, either version 3 of the License, or 00008 * (at your option) any later version. 00009 * 00010 * Camera.cc is distributed in the hope that it will be useful, but 00011 * WITHOUT ANY WARRANTY; without even the implied warranty of 00012 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 00013 * See the GNU General Public License for more details. 00014 * 00015 * You should have received a copy of the GNU General Public License along 00016 * with this program. If not, see <http://www.gnu.org/licenses/>. 00017 */ 00018 00019 #include "Camera.h" 00020 #include <iostream> 00021 00022 namespace uvsim 00023 { 00024 00025 Camera::Camera(int device) 00026 { 00027 m_capture = cvCreateCameraCapture(device); 00028 update(); // update to initialize m_frame 00029 } 00030 00031 Camera::~Camera() 00032 { 00033 cvReleaseCapture(&m_capture); 00034 } 00035 00036 void Camera::update() 00037 { 00038 m_frame = cvQueryFrame(m_capture); 00039 if (m_frame == NULL) 00040 { 00041 std::cerr << "Camera frame not allocated!" << std::endl; 00042 } 00043 } 00044 } // vim:ts=4:sw=4