working with opencv 2.4.8 and external devMgr

parent e73831e9
......@@ -20,19 +20,19 @@ SET( CMAKE_BUILD_TYPE Release)
INCLUDE (${PROJECT_SOURCE_DIR}/FindmvIMPACT.cmake)
#find the cv support and set HAVE_OPENCV_H for the conditional compilation
FIND_PACKAGE(OpenCV 3.1)
FIND_PACKAGE(OpenCV 2.4)
if (OpenCV_FOUND)
if (${OpenCV_VERSION_MAJOR} GREATER 2)
if (${OpenCV_VERSION_MAJOR} GREATER 1)
message("-- [INFO] Found OpenCV support")
ADD_DEFINITIONS(-DHAVE_OPENCV_H)
SET(USE_CV true)
else(${OpenCV_VERSION_MAJOR} GREATER 2)
message("[WARN] OpenCV support not installed. Minimum 3.0 version required. In case of using ROS, consider intalling OpenCV3 within ROS framework.")
else(${OpenCV_VERSION_MAJOR} GREATER 1)
message("[WARN] OpenCV support not installed. Minimum 2.4 version required.")
message("[WARN] Current version ${OpenCV_VERSION_MAJOR}")
endif(${OpenCV_VERSION_MAJOR} GREATER 2)
endif(${OpenCV_VERSION_MAJOR} GREATER 1)
else(OpenCV_FOUND)
message("[WARN] OpenCV support not installed. Minimum 3.0 version required. In case of using ROS, consider intalling OpenCV3 within ROS framework.")
message("[WARN] OpenCV support not installed. Minimum 2.4 version required.")
endif(OpenCV_FOUND)
# add the necessary include directories
......
# add the necessary include directories
INCLUDE_DIRECTORIES(.)
if (USE_CV)
# add the necessary include directories
INCLUDE_DIRECTORIES(. ${mvIMPACT_INCLUDE_DIR})
# create an example application
ADD_EXECUTABLE(mvbluefox3_test mvbluefox3_test.cpp)
......
......@@ -3,11 +3,17 @@
#include <unistd.h>
#ifdef HAVE_OPENCV_H
#include <opencv2/core/version.hpp>
#if CV_MAJOR_VERSION == 3
#include <opencv2/opencv.hpp>
#endif
#endif
#define WINDOW_NAME "mvBlueFOX3 TEST"
mvIMPACT::acquire::DeviceManager devMgr_; // Device Manager.
std::string GetSerialFromUser(void)
{
mvIMPACT::acquire::DeviceManager devMgr; // Device Manager.
......@@ -20,36 +26,36 @@ int main(int argc, char *argv[])
try {
// cam_ptr = new CMvbluefox3::CMvbluefox3(GetSerialFromUser());
cam_ptr = new CMvbluefox3::CMvbluefox3("F0300141");
cam_ptr = new CMvbluefox3::CMvbluefox3("F0300141",devMgr_);
CMvbluefox3::CParams params; //default parameters.
cam_ptr->SetConfig(params);
#ifdef HAVE_OPENCV_H
#if defined(HAVE_OPENCV_H) && CV_MAJOR_VERSION == 3
std::cout << "[Camera test]: Acquiring images." << std::endl;
cv::namedWindow( WINDOW_NAME, cv::WINDOW_NORMAL );
boost::timer t;
double duration;
boost::timer t;
double duration;
while (true)
{
t.restart();
t.restart();
cv::Mat image;
cam_ptr->GetImageCV(image);
cv::imshow( WINDOW_NAME, image );
if(cv::waitKey(30) >= 0) break;
// std::cout << '\r' << "fps:" << 1.0/t.elapsed() << std::flush;
std::cout << '\r' << "fps:" << 1.0/t.elapsed() << std::flush;
}
std::cout << std::endl;
std::cout << std::endl;
cv::destroyAllWindows();
#else
char *image=NULL;
cam_ptr->GetImage(&image);
std::cout << "[Camera test]: Frame acquired successfully."
<< "As no opencv is installed, visualization is avoided." << std::endl;
<< "OpenCV 3 is required and not installed, thus visualization is avoided." << std::endl;
delete [] image;
#endif
std::cout << "[Camera test]: Finished successfully." << std::endl;
......
......@@ -13,22 +13,26 @@
// uncomment this line to get more output into the console window
//#define VERBOSE_OUTPUT
// mvIMPACT::acquire::DeviceManager devMgr_; // Device Manager.
namespace CMvbluefox3 {
CMvbluefox3::CMvbluefox3(const std::string &serial)
CMvbluefox3::CMvbluefox3(const std::string &serial, const mvIMPACT::acquire::DeviceManager &dMan): devMgr_(dMan)
{
if( !serial.empty() )
{
std::cout << "[mvBlueFOX3]: Trying to open device with serial: " << serial << std::endl;
if (this->devMgr_.getDeviceBySerial(serial) == 0)
// if (this->devMgr_.getDeviceBySerial(serial) == 0)
if (devMgr_.getDeviceBySerial(serial) == 0)
{
throw CmvBlueFOX3Exception(_HERE_, "No device found! Unable to continue. " + AvailableDevices());
}
else
{
// create an interface to the found device
this->device_ = this->devMgr_[0];
// this->device_ = this->devMgr_[0];
this->device_ = devMgr_[0];
// Initialize other vars
this->timeout_ms_ = -1;
......@@ -69,7 +73,8 @@ std::string CMvbluefox3::AvailableDevices(SUPPORTED_DEVICE_CHECK pSupportedDevic
{
std::ostringstream devices;
devices << "Available device(s): ";
const unsigned int devCnt = this->devMgr_.deviceCount();
// const unsigned int devCnt = this->devMgr_.deviceCount();
const unsigned int devCnt = devMgr_.deviceCount();
if (devCnt == 0)
{
devices << "0.";
......@@ -78,7 +83,8 @@ std::string CMvbluefox3::AvailableDevices(SUPPORTED_DEVICE_CHECK pSupportedDevic
{
for( unsigned int i = 0; i < devCnt; i++ )
{
Device* pDev = this->devMgr_[i];
// Device* pDev = this->devMgr_[i];
Device* pDev = devMgr_[i];
if( pDev )
{
if( !pSupportedDeviceCheckFn || pSupportedDeviceCheckFn( pDev ) )
......@@ -221,7 +227,6 @@ void CMvbluefox3::GetImageCV(cv::Mat &image)
int type = CV_8UC1;
switch (this->depth_*this->bytes_per_pixel_)
switch (this->linepitch_)
{
case 8: type = CV_8UC1; break;
case 16: type = CV_8UC2; break;
......@@ -233,7 +238,7 @@ void CMvbluefox3::GetImageCV(cv::Mat &image)
image = cv::Mat(this->params_.height,this->params_.width,type,image_raw);
delete [] image_raw;
DelPtr(image_raw);
}
#endif
......
......@@ -366,7 +366,7 @@ class CMvbluefox3
*
* Class constructor.
*/
CMvbluefox3(const std::string &serial);
CMvbluefox3(const std::string &serial, const mvIMPACT::acquire::DeviceManager &dMan);
/**
* \brief Class destructor
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment