34 #include <opencv2/imgproc/imgproc.hpp>    35 #if CV_MAJOR_VERSION > 3    36 #include <opencv2/videoio/videoio_c.h>    38 #include <QtCore/QFile>    46         currentImageIndex_(0),
    49         qRegisterMetaType<cv::Mat>(
"cv::Mat");
    85                 return (
int)
capture_.get(CV_CAP_PROP_FRAME_COUNT);
    98                 return (
int)
capture_.get(CV_CAP_PROP_POS_FRAMES);
   109         else if(
capture_.isOpened() && frame < (int)
capture_.get(CV_CAP_PROP_FRAME_COUNT))
   111                 capture_.set(CV_CAP_PROP_POS_FRAMES, frame);
   166                 if( Settings::getCamera_2imageWidth() &&
   167                         Settings::getCamera_3imageHeight() &&
   168                         Settings::getCamera_2imageWidth() != img.cols &&
   169                         Settings::getCamera_3imageHeight() != img.rows)
   172                         cv::resize(img, resampled, cv::Size(Settings::getCamera_2imageWidth(), Settings::getCamera_3imageHeight()));
   190                 if(Settings::getCamera_6useTcpCamera())
   197                                 cameraTcpServer_ = 0;
   201                                 UINFO(
"CameraTCP: listening to port %d (IP=%s)",
   208                         QString path = Settings::getCamera_5mediaPath();
   212                                 QString ext = Settings::getGeneral_imageFormats();
   215                                 UDirectory dir(path.toStdString(), ext.toStdString()); 
   216                                 const std::list<std::string> & fileNames = dir.
getFileNames();
   220                                 for(std::list<std::string>::const_iterator iter = fileNames.begin(); iter!=fileNames.end(); ++iter)
   224                                 UINFO(
"Camera: Reading %d images from directory \"%s\"...", (
int)
images_.size(), path.toStdString().c_str());
   227                                         UWARN(
"Camera: Directory \"%s\" is empty (no images matching the \"%s\" extensions). "   228                                                    "If you want to disable loading automatically this directory, "   229                                                    "clear the Camera/mediaPath parameter. By default, webcam will be used instead of the directory.",
   230                                                    path.toStdString().c_str(),
   231                                                    ext.toStdString().c_str());
   234                         else if(!path.isEmpty())
   237                                 capture_.open(path.toStdString().c_str());
   240                                         UWARN(
"Camera: Cannot open file \"%s\". If you want to disable loading "   241                                                   "automatically this video file, clear the Camera/mediaPath parameter. "   242                                                   "By default, webcam will be used instead of the file.", path.toStdString().c_str());
   246                                         UINFO(
"Camera: Reading from video file \"%s\"...", path.toStdString().c_str());
   252                                 capture_.open(Settings::getCamera_1deviceId());
   253                                 if(Settings::getCamera_2imageWidth() && Settings::getCamera_3imageHeight())
   255                                         capture_.set(CV_CAP_PROP_FRAME_WIDTH, 
double(Settings::getCamera_2imageWidth()));
   256                                         capture_.set(CV_CAP_PROP_FRAME_HEIGHT, 
double(Settings::getCamera_3imageHeight()));
   258                                 UINFO(
"Camera: Reading from camera device %d...", Settings::getCamera_1deviceId());
   264                 UERROR(
"Camera: Failed to open a capture object!");
   285         if(Settings::getCamera_4imageRate())
   287                 cameraTimer_.setInterval((
int)(1000.0/Settings::getCamera_4imageRate()));
 
QHostAddress getHostAddress() const
static std::string separator()
const std::list< std::string > & getFileNames() const
void imageReceived(const cv::Mat &image)
int imagesBuffered() const
void moveToFrame(int frame)
virtual void updateImageRate()
unsigned int currentImageIndex_
Camera(QObject *parent=0)
CameraTcpServer * cameraTcpServer_
ULogger class and convenient macros. 
cv::VideoCapture capture_
static bool exists(const std::string &dirPath)
int getCurrentFrameIndex()
QList< std::string > images_