VAT
3.0
Video Analysis Tool
|
The CommonImage class This is a class made to solve the headache you'll probably get when working both in Qt and OpenCV. It's a QImage child class, so it's designed to work most of the time in Qt (to show the image in a QPixmap every frame, for example). As a bonus, it also has some methods to directly capture frames from a camera or a video file. More...
#include <commonimage.h>
Public Member Functions | |
CommonImage () | |
CommonImage Derived from all the QImage constructors. | |
CommonImage (const char *const xpm[]) | |
CommonImage (const QImage &q) | |
CommonImage (QImage *q) | |
CommonImage (const QSize &size, Format format) | |
CommonImage (const uchar *data, int width, int height, Format format, QImageCleanupFunction cleanupFunction, void *cleanupInfo) | |
CommonImage (const uchar *data, int width, int height, int bytesPerLine, Format format, QImageCleanupFunction cleanupFunction, void *cleanupInfo) | |
CommonImage (int width, int height, Format format) | |
CommonImage (uchar *data, int width, int height, Format format, QImageCleanupFunction cleanupFunction, void *cleanupInfo) | |
CommonImage (uchar *data, int width, int height, int bytesPerLine, Format format, QImageCleanupFunction cleanupFunction, void *cleanupInfo) | |
CommonImage (cv::Mat &source) | |
CommonImage::CommonImage Creates a CommonImage copying data from a cv::Mat. More... | |
CommonImage (const QString &fileName, const char *format) | |
CommonImage This constructor is reimplemented. If it fails to open a file using the QImage constructor (file is not an image), it tries to open it as a video. More... | |
CommonImage (int devNumber) | |
CommonImage::CommonImage Tries to open the camera specified by devNumber. More... | |
~CommonImage () | |
CommonImage::~CommonImage Takes a broom and <s>takes everything it finds below a carpet</s> cleans everything. | |
cv::Mat | toCVMat () |
CommonImage::toCVMat Copies this image data to a new allocated cv::Mat, which is returned. More... | |
void | toCVMat (cv::Mat &output) |
cv::Mat | toCVYUVMat () |
CommonImage::toCVYUVMat Copies and transforms this image data to a cv::Mat with a YUV (YCrCb) colorspace. More... | |
void | applyCVMask (const cv::Mat &mask) |
CommonImage::applyCVMask Applies a binary mask to this image. More... | |
bool | captureFromCamera (int device) |
CommonImage::captureFromCamera Opens the camera to grab images with grabCap(). If a file or a camera is currently being used, it is released. More... | |
bool | captureFromVideoFile (std::string fn) |
CommonImage::captureFromVideoFile Opens a video file to grab images with grabCap(). If a file or a camera is currently being used, it is released. More... | |
double | getCaptureAttribute (int propid) |
CommonImage::getCaptureAttribute Retrieves some attribute from the Video Capturer. More... | |
int | getCaptureFPS () |
CommonImage::getCaptureFPS Shows how many Frames Per Seconds does the captured media play. More... | |
int | getCaptureFrameInterval () |
CommonImage::getCaptureFrameInterval Shows the interval in milliseconds between two consecutive frames in the captured media play. More... | |
bool | captureSkipToTime (double secs) |
CommonImage::captureSkipToTime If capturing from a video file, this allows to skip to a video time. More... | |
bool | grabCap () |
void | closeCap () |
CommonImage::closeCap If a camera or video file is being used, it is closed. | |
void | convertFromMat (const cv::Mat &input) |
CommonImage::convertFromMat Copies the data from a cv::Mat. [I've got my doubts on whether this function has memory leaks or not. If it does, the main suspect is the rgbSwapped function at the end.]. More... | |
CommonImage & | operator= (const cv::Mat input) |
CommonImage::operator = A much more comfortable alias for convertFromMat. More... | |
Static Public Member Functions | |
static QImage | formatconv_CV2QT (const cv::Mat &input) |
CommonImage::formatconv_CV2QT Copies a CV Mat data to a new QImage. More... | |
static cv::Mat | formatconv_QT2CV (const QImage input) |
CommonImage::formatconv_QT2CV Copies a QImage data into a new OpenCV Mat. More... | |
static cv::Mat | formatconv_QT2CV_YUV (const QImage input) |
Protected Member Functions | |
void | cleanseCommonImageData () |
void | cleanseQImageData (int w=0, int h=0, Format fmt=QImage::Format_Invalid) |
CommonImage::cleanseQImageData This function is intended to resize and clean all the QImage data. [I'm pretty sure it has some SERIOUS memory leaks that I can't track (Is this->data reallocated or not?). Valgrind is a b*tch to use with Qt.]. More... | |
The CommonImage class This is a class made to solve the headache you'll probably get when working both in Qt and OpenCV. It's a QImage child class, so it's designed to work most of the time in Qt (to show the image in a QPixmap every frame, for example). As a bonus, it also has some methods to directly capture frames from a camera or a video file.
CommonImage::CommonImage | ( | cv::Mat & | source | ) |
CommonImage::CommonImage Creates a CommonImage copying data from a cv::Mat.
source | A cv::Mat image. |
CommonImage::CommonImage | ( | const QString & | fileName, |
const char * | format | ||
) |
CommonImage This constructor is reimplemented. If it fails to open a file using the QImage constructor (file is not an image), it tries to open it as a video.
fileName | Image or video path. |
format | Used only in image case. Ignored if opening a video. |
CommonImage::CommonImage | ( | int | devNumber | ) |
CommonImage::CommonImage Tries to open the camera specified by devNumber.
devNumber | Number of the camera to open. Use 0 to open the default camera. |
void CommonImage::applyCVMask | ( | const cv::Mat & | mask | ) |
CommonImage::applyCVMask Applies a binary mask to this image.
mask |
bool CommonImage::captureFromCamera | ( | int | device = 0 | ) |
CommonImage::captureFromCamera Opens the camera to grab images with grabCap(). If a file or a camera is currently being used, it is released.
device | Camera device index. Default is 0, which is the default camera. |
bool CommonImage::captureFromVideoFile | ( | std::string | fn | ) |
CommonImage::captureFromVideoFile Opens a video file to grab images with grabCap(). If a file or a camera is currently being used, it is released.
fn | Video file name. |
bool CommonImage::captureSkipToTime | ( | double | secs | ) |
CommonImage::captureSkipToTime If capturing from a video file, this allows to skip to a video time.
secs |
|
protected |
CommonImage::cleanseQImageData This function is intended to resize and clean all the QImage data. [I'm pretty sure it has some SERIOUS memory leaks that I can't track (Is this->data reallocated or not?). Valgrind is a b*tch to use with Qt.].
w | New image width. Default is 0, which absolutely empties this image. |
h | New image height. Default is 0, which absolutely empties this image. |
fmt | New image format. Default is QImage::Format_Invalid, a dummy to indicate that you want to keep the format intact. |
void CommonImage::convertFromMat | ( | const cv::Mat & | input | ) |
CommonImage::convertFromMat Copies the data from a cv::Mat. [I've got my doubts on whether this function has memory leaks or not. If it does, the main suspect is the rgbSwapped function at the end.].
input |
|
static |
CommonImage::formatconv_CV2QT Copies a CV Mat data to a new QImage.
input | CV Mat to be converted. |
|
static |
CommonImage::formatconv_QT2CV Copies a QImage data into a new OpenCV Mat.
input | A QImage. |
double CommonImage::getCaptureAttribute | ( | int | propid | ) |
CommonImage::getCaptureAttribute Retrieves some attribute from the Video Capturer.
propid | A requested attribute code (See VideoCapture::get method in OpenCV for more details) |
int CommonImage::getCaptureFPS | ( | ) |
CommonImage::getCaptureFPS Shows how many Frames Per Seconds does the captured media play.
int CommonImage::getCaptureFrameInterval | ( | ) |
CommonImage::getCaptureFrameInterval Shows the interval in milliseconds between two consecutive frames in the captured media play.
CommonImage & CommonImage::operator= | ( | const cv::Mat | input | ) |
cv::Mat CommonImage::toCVMat | ( | ) |
CommonImage::toCVMat Copies this image data to a new allocated cv::Mat, which is returned.
cv::Mat CommonImage::toCVYUVMat | ( | ) |
CommonImage::toCVYUVMat Copies and transforms this image data to a cv::Mat with a YUV (YCrCb) colorspace.