1 /* 2 Copyright (c) 2019 Ferhat Kurtulmuş 3 Boost Software License - Version 1.0 - August 17th, 2003 4 Permission is hereby granted, free of charge, to any person or organization 5 obtaining a copy of the software and accompanying documentation covered by 6 this license (the "Software") to use, reproduce, display, distribute, 7 execute, and transmit the Software, and to prepare derivative works of the 8 Software, and to permit third-parties to whom the Software is furnished to 9 do so, all subject to the following: 10 The copyright notices in the Software and this entire statement, including 11 the above license grant, this restriction and the following disclaimer, 12 must be included in all copies of the Software, in whole or in part, and 13 all derivative works of the Software, unless such copies or derivative 14 works are solely in the form of machine-executable object code generated by 15 a source language processor. 16 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT 19 SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE 20 FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE, 21 ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 22 DEALINGS IN THE SOFTWARE. 23 */ 24 25 module opencvd.video; 26 27 import opencvd.cvcore; 28 29 private { 30 extern (C){ 31 BackgroundSubtractorMOG2 BackgroundSubtractorMOG2_Create(); 32 void BackgroundSubtractorMOG2_Close(BackgroundSubtractorMOG2 b); 33 void BackgroundSubtractorMOG2_Apply(BackgroundSubtractorMOG2 b, Mat src, Mat dst); 34 35 BackgroundSubtractorKNN BackgroundSubtractorKNN_Create(); 36 void BackgroundSubtractorKNN_Close(BackgroundSubtractorKNN b); 37 void BackgroundSubtractorKNN_Apply(BackgroundSubtractorKNN b, Mat src, Mat dst); 38 39 void CalcOpticalFlowPyrLK(Mat prevImg, Mat nextImg, Mat prevPts, Mat nextPts, Mat status, Mat err); 40 void CalcOpticalFlowFarneback(Mat prevImg, Mat nextImg, Mat flow, double pyrScale, int levels, 41 int winsize, int iterations, int polyN, double polySigma, int flags); 42 } 43 } 44 45 struct _BackgroundSubtractorMOG2 { 46 void* p; 47 48 void close(){ 49 BackgroundSubtractorMOG2_Close(&this); 50 } 51 void apply(Mat src, Mat dst){ 52 BackgroundSubtractorMOG2_Apply(&this, src, dst); 53 } 54 } 55 56 alias BackgroundSubtractorMOG2 = _BackgroundSubtractorMOG2*; 57 58 BackgroundSubtractorMOG2 newBackgroundSubtractorMOG2(){ 59 return BackgroundSubtractorMOG2_Create(); 60 } 61 62 struct _BackgroundSubtractorKNN { 63 void*p; 64 65 void close(){ 66 BackgroundSubtractorKNN_Close(&this); 67 } 68 69 void apply(Mat src, Mat dst){ 70 BackgroundSubtractorKNN_Apply(&this, src, dst); 71 } 72 } 73 74 alias BackgroundSubtractorKNN = _BackgroundSubtractorKNN*; 75 76 BackgroundSubtractorKNN newBackgroundSubtractorKNN(){ 77 return BackgroundSubtractorKNN_Create(); 78 } 79 80 void calcOpticalFlowPyrLK(Mat prevImg, Mat nextImg, Mat prevPts, Mat nextPts, Mat status, Mat err){ 81 CalcOpticalFlowPyrLK(prevImg, nextImg, prevPts, nextPts, status, err); 82 } 83 84 void calcOpticalFlowFarneback(Mat prevImg, Mat nextImg, Mat flow, double pyrScale, int levels, 85 int winsize, int iterations, int polyN, double polySigma, int flags){ 86 CalcOpticalFlowFarneback(prevImg, nextImg, flow, pyrScale, levels, 87 winsize, iterations, polyN, polySigma, flags); 88 }