added cuda support for opencv plugin
[profile/ivi/automotive-message-broker.git] / plugins / opencvlux / opencvluxplugin.h
1 /*
2 Copyright (C) 2012 Intel Corporation
3
4 This library is free software; you can redistribute it and/or
5 modify it under the terms of the GNU Lesser General Public
6 License as published by the Free Software Foundation; either
7 version 2.1 of the License, or (at your option) any later version.
8
9 This library is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
12 Lesser General Public License for more details.
13
14 You should have received a copy of the GNU Lesser General Public
15 License along with this library; if not, write to the Free Software
16 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
17 */
18
19 #ifndef OPENCVLUXPLUGIN_H
20 #define OPENCVLUXPLUGIN_H
21
22 #include <abstractsource.h>
23 #include <string>
24
25 #include <opencv/cv.h>
26 #include <opencv/highgui.h>
27
28 using namespace std;
29
30 class OpenCvLuxPlugin: public AbstractSource
31 {
32
33 public:
34
35         struct Shared
36         {
37                 cv::VideoCapture *m_capture;
38                 PropertyList mRequests;
39                 OpenCvLuxPlugin* parent;
40
41                 double fps;
42                 bool threaded;
43                 bool kinect;
44                 bool useOpenCl;
45         bool useCuda;
46                 int pixelLowerBound;
47                 int pixelUpperBound;
48         };
49
50         OpenCvLuxPlugin(AbstractRoutingEngine* re, map<string, string> config);
51         
52         const string uuid();
53         void getPropertyAsync(AsyncPropertyReply *reply);
54         void getRangePropertyAsync(AsyncRangePropertyReply *reply);
55         AsyncPropertyReply * setProperty(AsyncSetPropertyRequest request);
56         void subscribeToPropertyChanges(VehicleProperty::Property property);
57         void unsubscribeToPropertyChanges(VehicleProperty::Property property);
58         PropertyList supported();
59
60         int supportedOperations();
61         
62         void supportedChanged(PropertyList) {}
63         
64         void updateProperty(uint lux);
65
66
67
68         
69 private: /// methods:
70         bool init();
71
72 private:        
73         uint lastLux;
74         std::string device;
75         std::list<AsyncPropertyReply*> replyQueue;
76
77         Shared* shared;
78 };
79
80 static int grabImage(void *data);
81 static uint evalImage(cv::Mat qImg, OpenCvLuxPlugin::Shared *shared);
82
83
84 #endif // EXAMPLEPLUGIN_H