/**
    05Robot - Computer Vision Module

    @author P.Kaczmarek,J.Tomczynski,T.Mankowski
    @version 1.0 2017
*/
#ifndef PROCESSOR_H
#define PROCESSOR_H

#include <string>
#include <vector>
#include <QObject>
#include <QTime>

#include "common.h"

#include <opencv2/opencv.hpp>

#include "cxmlio.h"

using namespace std;
/** \addtogroup ComputerVisionModule
 *  @{
 */
/**
 @brief Image processor base class
 */
class Processor : public cXmlIO
{
	Q_OBJECT

public:
    /**
     @brief Starts internal clock
     */
	Processor() {
		m_time.start();
	}
	
public:
    
    /**
     * @brief Processor input data type enum
     */
    enum InputType {
        InputTypeMat, /**< image */
        InputTypePoint2, /**< vector of 2D points */
        InputTypePoint3  /**< vector of 3D points */
    };
    /**
     * @brief Processor input data type
     */
	InputType inputType;
    /**
     * @brief Vector of input images
     */
	vector<cv::Mat *> inputMat;
    /**
     * @brief Vector of input series of 2D points
     */
	vector<vector<cv::Point2f> *> inputPoint2;
    /**
     * @brief Vector of input series of 3D points
     */
	vector<vector<cv::Point3d> *> inputPoint3;
    /**
     * @brief Vector of pointers to connected cameras names
     */
	vector<QString *> cameraName;
    /**
     * @brief Vector of output images
     */
	vector<cv::Mat *> outputMat;
    /**
     * @brief Vector of output series of 2D points
     */
    vector<vector<cv::Point2f> *> outputPoint2;
    /**
     * @brief Vector of input series of 3D points
     */
	vector<vector<cv::Point3d> *> outputPoint3;
    /**
     * @brief Internal clock
     */
	QTime m_time;

public:
    /**
     @brief Starts image processing, should be overridden in descendant class
     
     @return 0 on success
     */
	virtual int start();
    /**
     @brief Processes frames in input buffer, should be overridden in descendant class
     
     @param t1 Cameras trigger time
     @param t2 Cameras acquisition finish time
     @return 0 on success
     */
	virtual int process(int t1,int t2);
    /**
     @brief Processes special command, should be overridden in descendant class
     
     @param s Command string
     @return 0 on success
     */
	virtual int processSpecial(string s);
    /**
     @brief Stops image processing, should be overridden in descendant class
     
     @return 0 on success
     */
	virtual int stop();

signals:
	/**
	 @brief Data logger

	 @param info text to log
	 */
	void writeInfo(QString info);

};
/** @}*/
#endif
