Subversion Repositories seema-scanner

Rev

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

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