Subversion Repositories seema-scanner

Rev

Rev 17 | Go to most recent revision | Blame | Compare with Previous | Last modification | View Log | RSS feed

#include "Camera.h"
#include "CameraPointGrey.h"
#include <opencv2/opencv.hpp>

int main(int argc, char *argv[]){

    std::vector< std::vector<CameraInfo> > camInfo = Camera::GetInterfaceCameraList();

    for(unsigned int i=0; i<camInfo.size(); i++){
        for(unsigned int j=0; j<camInfo[i].size(); j++){
            CameraInfo info = camInfo[i][j];
            std::cout << "(" << i << "," << j << ")" << info.vendor << " " << info.model << " " << info.busID << std::endl;
        }
    }

    Camera *cam = Camera::NewCamera(0, 0, triggerModeSoftware);
    cam->startCapture();

    vector<int> compression_params;
    compression_params.push_back(CV_IMWRITE_JPEG_QUALITY);
    compression_params.push_back(95);

    for(int i=0; i<5; i++){
        CameraFrame frame = cam->getFrame();
        cv::Mat frameCV(frame.height, frame.width, CV_16UC3, frame.memory);
        cv::Mat frameCV8bit;
        frameCV.convertTo(frameCV8bit, CV_8UC3, 1.0/255.0);
        cv::cvtColor(frameCV8bit, frameCV8bit, CV_RGB2BGR);
        char filename[10];
        sprintf(filename, "%d.jpg", i);
        cv::imwrite(std::string(filename), frameCV8bit, compression_params);
    }

    cam->stopCapture();

}