qhdrcamera.h 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. #ifndef QHDRCAMERA_H
  2. #define QHDRCAMERA_H
  3. #include "QNativeCamera.h"
  4. #include <QGenericMatrix>
  5. #include <QThreadPool>
  6. class HdrThread :public QRunnable
  7. {
  8. public:
  9. HdrThread(QImage*,QImage*);
  10. private:
  11. QImage* image;
  12. QImage* result;
  13. protected:
  14. void run();
  15. };
  16. class QHdrCamera : public QNativeCamera
  17. {
  18. Q_OBJECT
  19. Q_CLASSINFO("Author", "Sebastiano Galazzo")
  20. Q_CLASSINFO("Email", "sebastiano.galazzo@gmail.com")
  21. Q_PROPERTY(qreal exposureRange READ exposureRange WRITE setExposureRange NOTIFY exposureRangeChanged)
  22. Q_PROPERTY(unsigned short shots READ shots WRITE setShots NOTIFY shotsChanged)
  23. public:
  24. explicit QHdrCamera(QDeclarativeItem *parent = 0);
  25. unsigned short shots();
  26. void setShots(unsigned short value);
  27. qreal exposureRange();
  28. void setExposureRange(qreal value);
  29. static float brightness( const char r, const char g, const char b);
  30. //static float gray( const char r, const char g, const char b);
  31. static float gray( const float r, const float g, const float b);
  32. static float saturation( const float r, const float g, const float b);
  33. static void laplace(QImage& in, QImage& out);
  34. //static int gauss(QImage& in, QImage& out, double sigma=0.35);
  35. static int gauss(QImage& in, QImage& out, double sigma=0.2);
  36. static void mul(QVector<QImage*>& ins, QImage& out, int k=0);
  37. static void add(QVector<QImage*>& ins, QImage& out, bool average=true);
  38. signals:
  39. void started();
  40. void finished(QString pathResultImage, QString pathOriginalImage);
  41. void merging();
  42. void shotsChanged(int value);
  43. void exposureRangeChanged(qreal value);
  44. void processedShot1();
  45. void processedShot2();
  46. void processedShot3();
  47. public slots:
  48. void captureImage();
  49. private slots:
  50. void process();
  51. void imageAvailable(int,QVideoFrame);
  52. void imageCaptured ( int id, const QImage & preview );
  53. private:
  54. /*QImage shot1;
  55. QImage shot2;
  56. QImage shot3;*/
  57. QVector<QImage*> shot;
  58. QVector<QImage*> tShot;
  59. QVector<QVideoFrame> vFrame;
  60. /*QImage tImage1;
  61. QImage tImage2;
  62. QImage tImage3;*/
  63. unsigned short m_shots;
  64. qreal m_exposureRange;
  65. static QMatrix3x3 convol;
  66. };
  67. #endif // QHDRCAMERA_H