almost working. only raw messages to be fixed in ros node

parent c8686a52
This diff is collapsed.
#include "mvbluefox3.h"
#include <unistd.h>
#include <limits.h>
#include <sstream>
#ifdef HAVE_OPENCV_H
......@@ -12,7 +12,7 @@
typedef bool( *SUPPORTED_DEVICE_CHECK )( const mvIMPACT::acquire::Device* const );
mvIMPACT::acquire::DeviceManager devMgr_; // Device Manager.
// mvIMPACT::acquire::DeviceManager devMgr_; // Device Manager.
std::string GetSerialFromUser(void)
......@@ -35,7 +35,7 @@ std::string AvailableDevices(SUPPORTED_DEVICE_CHECK pSupportedDeviceCheckFn)
{
for( unsigned int i = 0; i < devCnt; i++ )
{
Device* pDev = devMgr_[i];
Device* pDev = devMgr[i];
if( pDev )
{
if( !pSupportedDeviceCheckFn || pSupportedDeviceCheckFn( pDev ) )
......@@ -48,22 +48,42 @@ std::string AvailableDevices(SUPPORTED_DEVICE_CHECK pSupportedDeviceCheckFn)
return devices.str();
}
std::string GetPath()
{
char result[ PATH_MAX ];
ssize_t count = readlink( "/proc/self/exe", result, PATH_MAX );
return std::string( result, (count > 0) ? count : 0 );
}
int main(int argc, char *argv[])
{
int num_cams = 2;
int num_cams = 1;
// Get own path
std::string argv_str(argv[0]);
std::string pbase = argv_str.substr(0, argv_str.find_last_of("/"));
std::string paramspath = pbase + "/../src/examples/example_params.xml";
std::cout << std::endl;
std::cout << "******************************" << std::endl;
std::cout << "* ---- mvBlueFOX3 test ---- *" << std::endl;
std::cout << "******************************" << std::endl;
std::cout << std::endl;
std::cout << "Please, choose the device to test from the following list:" << std::endl;
std::cout << std::endl;
std::vector<std::string> serial;
serial.resize(num_cams);
serial[0] = "F0300141";
serial[1] = "F0300123";
serial[0] = GetSerialFromUser();
#if defined(HAVE_OPENCV_H) && CV_MAJOR_VERSION == 3
std::vector<std::string> window_name;
window_name.resize(num_cams);
window_name[0] = serial[0];
window_name[1] = serial[1];
#endif
mvIMPACT::acquire::DeviceManager devMgr_; // Device Manager.
std::vector<CMvbluefox3::CMvbluefox3*> cam_ptr;
cam_ptr.resize(num_cams);
for (int ii = 0; ii < num_cams; ++ii)
......@@ -72,7 +92,7 @@ int main(int argc, char *argv[])
if( !serial[ii].empty() )
{
std::cout << "[mvBlueFOX3]: Trying to open device with serial: " << serial[ii] << std::endl;
std::cout << "Trying to open device with serial: " << serial[ii] << std::endl;
if (devMgr_.getDeviceBySerial(serial[ii]) == 0)
{
......@@ -81,7 +101,7 @@ int main(int argc, char *argv[])
else
{
// create an interface to the found device
cam_ptr[ii] = new CMvbluefox3::CMvbluefox3(devMgr_.getDeviceBySerial(serial[ii]));
cam_ptr[ii] = new CMvbluefox3::CMvbluefox3(devMgr_.getDeviceBySerial(serial[ii]),paramspath);
}
}
else
......@@ -90,15 +110,8 @@ int main(int argc, char *argv[])
try {
for (int ii = 0; ii < num_cams; ++ii)
{
CMvbluefox3::CParams params; //default parameters.
params.pixel_format = CMvbluefox3::rgb8;
cam_ptr[ii]->SetConfig(params);
}
#if defined(HAVE_OPENCV_H) && CV_MAJOR_VERSION == 3
std::cout << "[Camera test]: Acquiring images." << std::endl;
std::cout << "Acquiring images. WARNING: depending on OpenCV compilation flags, visualization might experience hard delays (e.g. if \"init done\" appears in the following line)" << std::endl;
for (int ii = 0; ii < num_cams; ++ii)
cv::namedWindow( window_name[ii], cv::WINDOW_NORMAL );
......
......@@ -72,9 +72,8 @@ void CMvbluefox3::OpenDevice(const std::string &sett_path)
if (!sett_path.empty())
LoadSettings(sett_path);
// Uncomment this function in case of filling manually the parameters before creating the CMvbluefox3 object externally, otherwise LoadSettings function will be used.
// SetConfig(this->params_,true);
else
SetConfig(this->params_,true);
}
void CMvbluefox3::CloseDevice(void)
......@@ -202,6 +201,7 @@ void CMvbluefox3::GetImageCV(cv::Mat &image)
}
image = cv::Mat(this->params_.height,this->params_.width,type,image_raw);
cv::cvtColor(image, image, CV_BGR2RGB); // Opencv uses BGR.
DelPtr(image_raw);
}
......@@ -237,8 +237,20 @@ void CMvbluefox3::GetImageReqFormat(mvIMPACT::acquire::Request *request)
this->params_.pixel_format = MVFormatToEncoding(idpf);
}
else // Bayer pattern
{
this->params_.pixel_format = BayerPatternToEncoding(bayer_mosaic_parity,
this->bytes_per_pixel_);
}
}
int CMvbluefox3::GetBytesPixel(void)
{
return this->bytes_per_pixel_;
}
int CMvbluefox3::GetDepth(void)
{
return this->depth_;
}
int CMvbluefox3::GetImgLinePitch(void)
......
......@@ -426,6 +426,20 @@ class CMvbluefox3
*/
CParams GetConfig(void);
/**
* \brief Get bytes per pixel
*
* Get bytes per pixel.
*/
int GetBytesPixel(void);
/**
* \brief Get image depth (channels)
*
* Get image depth (channels).
*/
int GetDepth(void);
/**
* \brief Get line pitch
*
......
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