//
// Created by qiayuan on 6/27/20.
//

#ifndef SRC_GALAXY_CAMERA_INCLUDE_GALAXY_CAMERA_H_
#define SRC_GALAXY_CAMERA_INCLUDE_GALAXY_CAMERA_H_

#include "libgxiapi/GxIAPI.h"
#include "libgxiapi/DxImageProc.h"
#include <image_transport/image_transport.h>
#include <unistd.h>

namespace galaxy_camera {
    class GalaxyCamera {
    public:
        GalaxyCamera(const ros::NodeHandle &nh,
                     image_transport::CameraPublisher &pub,
                     sensor_msgs::CameraInfo info,
                     uint32_t height, uint32_t width, uint32_t step,
                     uint32_t offset_x, uint32_t offset_y,
                     const std::string &encoding,
                     const std::string &camera_name,
                     const bool &trigger_open);

        ~GalaxyCamera();
        void writeConfig();
        bool chooseCameraModel();
        static sensor_msgs::Image image_;
        

    private:
        GX_DEV_HANDLE dev_handle_{};
        int last_channel_ = 0;
        ros::NodeHandle nh_;
        double frame_rate;
        bool trigger_open_;
        static char *img;
        static image_transport::CameraPublisher pub_;
        static sensor_msgs::CameraInfo info_;

        static void GX_STDC onFrameCB(GX_FRAME_CALLBACK_PARAM *pFrame);

    };
}

#endif //SRC_GALAXY_CAMERA_INCLUDE_GALAXY_CAMERA_H_
