OSDN Git Service

add JPG and TIFF Support via OpenCV for Image::load and Image::save
[psychlops/cpp.git] / psychlops / extension / FileFormat / OpenCV / psychlops_g_OPENCV_bridge.cpp
1 /*
2  *  psychlops_g_PNG_bridge.cpp
3  *  Psychlops Standard Library (Universal)
4  *
5  *  Last Modified 2006/08/22 by Kenchi HOSOKAWA
6  *  (C) 2006- Kenchi HOSOKAWA, Kazushi MARUYA and Takao SATO
7  */
8
9 #include <stdio.h>
10 #include <stdlib.h>\r
11 #include <opencv2/highgui/highgui.hpp>
12
13 #include "../../../core/ApplicationInterfaces/psychlops_code_exception.h"
14 #include "../../../core/graphic/psychlops_g_image.h"
15 #include "psychlops_g_OPENCV_bridge.h"
16
17
18 namespace Psychlops {
19 namespace IMAGE_FORMATS {
20
21
22         OPENCV_BRIDGE::OPENCV_BRIDGE() {
23         }
24         OPENCV_BRIDGE::~OPENCV_BRIDGE() {
25         }
26
27
28         void OPENCV_BRIDGE::load(const char *file_name, Image * target) {\r
29                 std::string file(file_name);\r
30                 cv::Mat img = cv::imread(file, -1);\r
31                 target->from(img);
32         }
33         void OPENCV_BRIDGE::save(const char *file_name, Image * target) {\r
34                 std::string file(file_name);\r
35                 cv::Mat img;\r
36                 target->to(img);\r
37                 cv::imwrite(file, img);
38         }
39
40
41 }
42 }