2 Copyright (C) 2012 Intel Corporation
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.
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.
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
19 #ifndef OPENCVLUXPLUGIN_H
20 #define OPENCVLUXPLUGIN_H
22 #include <abstractsource.h>
26 #include <opencv/cv.h>
27 #include <opencv2/highgui/highgui.hpp>
34 class OpenCvLuxPlugin: public QObject, public AbstractSource
39 typedef BasicPropertyType<bool> DriverDrowsinessType;
43 std::unique_ptr<cv::VideoCapture> m_capture;
44 std::unique_ptr<cv::VideoWriter> mWriter;
45 PropertyList mRequests;
46 OpenCvLuxPlugin* parent;
59 OpenCvLuxPlugin(AbstractRoutingEngine* re, map<string, string> config);
64 void getPropertyAsync(AsyncPropertyReply *reply);
65 void getRangePropertyAsync(AsyncRangePropertyReply *reply);
66 AsyncPropertyReply * setProperty(AsyncSetPropertyRequest request);
67 void subscribeToPropertyChanges(VehicleProperty::Property property);
68 void unsubscribeToPropertyChanges(VehicleProperty::Property property);
69 PropertyList supported();
71 int supportedOperations();
73 void propertyChanged(AbstractPropertyType* value);
75 void supportedChanged(const PropertyList &);
77 void updateProperty(uint lux);
79 void writeVideoFrame(cv::Mat frame);
81 void detectEyes(cv::Mat frame);
99 std::list<AsyncPropertyReply*> replyQueue;
101 std::unique_ptr<VehicleProperty::ExteriorBrightnessType> extBrightness;
103 std::unique_ptr<Shared> shared;
106 std::unique_ptr<cv::CascadeClassifier> faceCascade;
107 std::unique_ptr<cv::CascadeClassifier> eyeCascade;
109 std::unique_ptr<DriverDrowsinessType> driverDrowsiness;
111 std::unique_ptr<BasicPropertyType<bool>> openCl;
114 static int grabImage(void *data);
115 static uint evalImage(cv::Mat qImg, OpenCvLuxPlugin::Shared *shared);
117 namespace TrafficLight
128 TrafficLight::Color detectLight(cv::Mat img, OpenCvLuxPlugin::Shared* shared);
131 #endif // EXAMPLEPLUGIN_H