You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

90 lines
2.0 KiB

7 years ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
  1. /*
  2. Fl_OpenCv 0.7
  3. Licanse : LGPL
  4. Fl_OpenCv is a widget which is render OpenCv image within the FLTK window
  5. Programmed by BlueKid
  6. http://derindelimavi.blogspot.com/
  7. Sent me any suggestion, modification or bugs. Don't hesitate to contact
  8. me for any question, I will be very grateful with your feedbacks.
  9. bluekid70@gmail.com
  10. */
  11. #ifndef Fl_OpenCV_H
  12. #define Fl_OpenCV_H
  13. #include <FL/Fl_Widget.H>
  14. #include <FL/fl_ask.H>
  15. #include <opencv2/opencv.hpp>
  16. //#include <opencv/highgui.h>
  17. IplImage *fl_LoadImage(char*filename,int iscolor);
  18. bool fl_SaveImage(char*filename,IplImage *image);
  19. class Fl_Capture {
  20. protected:
  21. CvCapture *cap;
  22. IplImage *frame;
  23. public:
  24. // Video
  25. bool CaptureFromFile( char* filename );
  26. bool CaptureFromCAM( int index );
  27. int GrabFrame();
  28. void RetrieveFrame();
  29. void QueryFrame();
  30. IplImage * GetFrame();
  31. void ShowFrame();
  32. double GetPositionMs();
  33. double GetPositionFrame();
  34. double GetPositionPercent();
  35. double GetFrameWidth();
  36. double GetFrameHeight();
  37. double GetFPS();
  38. double GetCodec();
  39. int SetPositionMs(double value);
  40. int SetPositionFrame(double value);
  41. int SetPositionPercent(double value);
  42. int SetFrameWidth(double value);
  43. int SetFrameHeight(double value);
  44. int SetFPS(double value);
  45. int SetCodec(double value);
  46. ~Fl_Capture();
  47. };
  48. class FL_EXPORT Fl_OpenCV : public Fl_Widget
  49. {
  50. int _x,_y,_w,_h;
  51. protected:
  52. IplImage *fimage;
  53. int iscolor;
  54. bool fit;
  55. void draw(int,int,int,int);
  56. void draw(){
  57. draw(Fl_Widget::x(),Fl_Widget::y(),w(),h());
  58. }
  59. void x(int X){ _x=X;};
  60. void y(int Y){ _y=Y;};
  61. void w(int W){ _w=W;};
  62. void h(int H){ _h=H;};
  63. public:
  64. IplImage *image;
  65. int x(){return _x;};
  66. int y(){return _y;};
  67. int w(){return _w;};
  68. int h(){return _h;};
  69. bool Load(char*filename,int iscolor=1);
  70. bool Save(char*filename);
  71. void SetImage(IplImage *nimage);
  72. void FitWindows();
  73. Fl_OpenCV(int X, int Y,int W,int H,char *file_name=NULL);
  74. Fl_OpenCV(int X, int Y);
  75. ~Fl_OpenCV();
  76. };
  77. #endif