Subversion Repositories seema-scanner

Rev

Rev 23 | Only display areas with differences | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 23 Rev 205
1
#include "Camera.h"
1
#include "Camera.h"
2
#include "CameraPointGrey.h"
2
#include "CameraPointGrey.h"
3
#include <opencv2/opencv.hpp>
3
#include <opencv2/opencv.hpp>
4
#include "cvtools.h"
4
#include "cvtools.h"
5
 
5
 
6
int main(int argc, char *argv[]){
6
int main(int argc, char *argv[]){
7
 
7
 
8
    std::vector< std::vector<CameraInfo> > camInfo = Camera::GetInterfaceCameraList();
8
    std::vector< std::vector<CameraInfo> > camInfo = Camera::GetInterfaceCameraList();
9
 
9
 
10
    for(unsigned int i=0; i<camInfo.size(); i++){
10
    for(unsigned int i=0; i<camInfo.size(); i++){
11
        for(unsigned int j=0; j<camInfo[i].size(); j++){
11
        for(unsigned int j=0; j<camInfo[i].size(); j++){
12
            CameraInfo info = camInfo[i][j];
12
            CameraInfo info = camInfo[i][j];
13
            std::cout << "(" << i << "," << j << ")" << info.vendor << " " << info.model << " " << info.busID << std::endl;
13
            std::cout << "(" << i << "," << j << ")" << info.vendor << " " << info.model << " " << info.busID << std::endl;
14
        }
14
        }
15
    }
15
    }
16
 
16
 
17
    Camera *cam = Camera::NewCamera(0, 0, triggerModeSoftware);
17
    Camera *cam = Camera::NewCamera(0, 0, triggerModeSoftware);
18
    cam->startCapture();
18
    cam->startCapture();
19
 
19
 
20
    vector<int> compression_params;
20
    vector<int> compression_params;
21
    compression_params.push_back(CV_IMWRITE_JPEG_QUALITY);
21
    compression_params.push_back(CV_IMWRITE_JPEG_QUALITY);
22
    compression_params.push_back(95);
22
    compression_params.push_back(95);
23
 
23
 
24
    for(int i=0; i<5; i++){
24
    for(int i=0; i<5; i++){
25
        CameraFrame frame = cam->getFrame();
25
        CameraFrame frame = cam->getFrame();
26
        cv::Mat frameCV(frame.height, frame.width, CV_8UC3, frame.memory);
26
        cv::Mat frameCV(frame.height, frame.width, CV_8UC3, frame.memory);
27
        // save as matlab mat file
27
        // save as matlab mat file
28
        char filename[10];
28
        char filename[10];
29
        sprintf(filename, "%d.mat", i);
29
        sprintf(filename, "%d.mat", i);
30
        cvtools::writeMat(frameCV, filename, "frame");
30
        cvtools::writeMat(frameCV, filename, "frame");
31
        // save as jpg image
31
        // save as jpg image
32
        cv::cvtColor(frameCV, frameCV, CV_RGB2BGR);
32
        cv::cvtColor(frameCV, frameCV, CV_RGB2BGR);
33
        sprintf(filename, "%d.jpg", i);
33
        sprintf(filename, "%d.jpg", i);
34
        cv::imwrite(std::string(filename), frameCV, compression_params);
34
        cv::imwrite(std::string(filename), frameCV, compression_params);
35
    }
35
    }
36
 
36
 
37
    cam->stopCapture();
37
    cam->stopCapture();
38
 
38
 
39
}
39
}
40
 
40