forked from justadudewhohacks/opencv4nodejs
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
BackgroundSubtractors refactored + added testcases
- Loading branch information
1 parent
c2ac476
commit 9f8dfcb
Showing
11 changed files
with
262 additions
and
95 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
# BackgroundSubtractorKNN | ||
|
||
## Accessors | ||
``` javascript | ||
BackgroundSubtractorKNN { | ||
history: Uint, | ||
dist2Threshold: Number, | ||
detectShadows: Boolean | ||
} | ||
``` | ||
|
||
<a name="constructors"></a> | ||
|
||
## Constructors | ||
``` javascript | ||
BackgroundSubtractorKNN : new BackgroundSubtractorKNN(Uint history = 500, Number varThreshold = 400, Boolean detectShadows = true) | ||
``` | ||
## Methods | ||
|
||
<a name="apply"></a> | ||
|
||
### apply | ||
``` javascript | ||
Mat : bgsubtractor.apply(Mat frame, Number learningRate = -1) | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
# BackgroundSubtractorMOG2 | ||
|
||
## Accessors | ||
``` javascript | ||
BackgroundSubtractorMOG2 { | ||
history: Uint, | ||
varThreshold: Number, | ||
detectShadows: Boolean | ||
} | ||
``` | ||
|
||
<a name="constructors"></a> | ||
|
||
## Constructors | ||
``` javascript | ||
BackgroundSubtractorMOG2 : new BackgroundSubtractorMOG2(Uint history = 500, Number varThreshold = 16, Boolean detectShadows = true) | ||
``` | ||
## Methods | ||
|
||
<a name="apply"></a> | ||
|
||
### apply | ||
``` javascript | ||
Mat : bgsubtractor.apply(Mat frame, Number learningRate = -1) | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
# video |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
const cv = global.dut; | ||
const { | ||
assertMetaData, | ||
assertPropsWithValue, | ||
funcShouldRequireArgs, | ||
readTestImage | ||
} = global.utils; | ||
const { expect } = require('chai'); | ||
|
||
module.exports = () => { | ||
describe('BackgroundSubtractorKNN', () => { | ||
const history = 1000; | ||
const dist2Threshold = 100.5; | ||
const detectShadows = false; | ||
|
||
describe('constructor', () => { | ||
it('should be constructable with default args', () => { | ||
expect(() => new cv.BackgroundSubtractorKNN()).to.not.throw(); | ||
}); | ||
|
||
it('should be constructable with optional args', () => { | ||
const bgsubtractor = new cv.BackgroundSubtractorKNN( | ||
history, | ||
dist2Threshold, | ||
detectShadows | ||
); | ||
assertPropsWithValue(bgsubtractor)({ | ||
history, | ||
dist2Threshold, | ||
detectShadows | ||
}); | ||
}); | ||
|
||
it('should be constructable with optional args object', () => { | ||
const bgsubtractor = new cv.BackgroundSubtractorKNN({ | ||
history, | ||
dist2Threshold, | ||
detectShadows | ||
}); | ||
assertPropsWithValue(bgsubtractor)({ | ||
history, | ||
dist2Threshold, | ||
detectShadows | ||
}); | ||
}); | ||
|
||
it('should implement apply', () => { | ||
const bgsubtractor = new cv.BackgroundSubtractorKNN(); | ||
expect(bgsubtractor).to.have.property('apply').to.be.a('function'); | ||
}); | ||
}); | ||
|
||
describe('apply', () => { | ||
let testImg; | ||
|
||
before(() => { | ||
testImg = readTestImage(); | ||
}); | ||
|
||
const learningRate = 2.5; | ||
|
||
funcShouldRequireArgs(() => new cv.BackgroundSubtractorKNN().apply()); | ||
|
||
it('can be called if required args passed', () => { | ||
const bgsubtractor = new cv.BackgroundSubtractorKNN(); | ||
const fgMask = bgsubtractor.apply(testImg); | ||
expect(fgMask).instanceOf(cv.Mat); | ||
assertMetaData(fgMask)(testImg.rows, testImg.cols, cv.CV_8U); | ||
}); | ||
|
||
it('can be called with learningRate', () => { | ||
const bgsubtractor = new cv.BackgroundSubtractorKNN(); | ||
const fgMask = bgsubtractor.apply(testImg, learningRate); | ||
expect(fgMask).instanceOf(cv.Mat); | ||
assertMetaData(fgMask)(testImg.rows, testImg.cols, cv.CV_8U); | ||
}); | ||
}); | ||
}); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
const cv = global.dut; | ||
const { | ||
assertMetaData, | ||
assertPropsWithValue, | ||
funcShouldRequireArgs, | ||
readTestImage | ||
} = global.utils; | ||
const { expect } = require('chai'); | ||
|
||
module.exports = () => { | ||
describe('BackgroundSubtractorMOG2', () => { | ||
const history = 1000; | ||
const varThreshold = 8; | ||
const detectShadows = false; | ||
|
||
describe('constructor', () => { | ||
it('should be constructable with default args', () => { | ||
expect(() => new cv.BackgroundSubtractorMOG2()).to.not.throw(); | ||
}); | ||
|
||
it('should be constructable with optional args', () => { | ||
const bgsubtractor = new cv.BackgroundSubtractorMOG2( | ||
history, | ||
varThreshold, | ||
detectShadows | ||
); | ||
assertPropsWithValue(bgsubtractor)({ | ||
history, | ||
varThreshold, | ||
detectShadows | ||
}); | ||
}); | ||
|
||
it('should be constructable with optional args object', () => { | ||
const bgsubtractor = new cv.BackgroundSubtractorMOG2({ | ||
history, | ||
varThreshold, | ||
detectShadows | ||
}); | ||
assertPropsWithValue(bgsubtractor)({ | ||
history, | ||
varThreshold, | ||
detectShadows | ||
}); | ||
}); | ||
|
||
it('should implement apply', () => { | ||
const bgsubtractor = new cv.BackgroundSubtractorMOG2(); | ||
expect(bgsubtractor).to.have.property('apply').to.be.a('function'); | ||
}); | ||
}); | ||
|
||
describe('apply', () => { | ||
let testImg; | ||
|
||
before(() => { | ||
testImg = readTestImage(); | ||
}); | ||
|
||
const learningRate = 2.5; | ||
|
||
funcShouldRequireArgs(() => new cv.BackgroundSubtractorMOG2().apply()); | ||
|
||
it('can be called if required args passed', () => { | ||
const bgsubtractor = new cv.BackgroundSubtractorMOG2(); | ||
const fgMask = bgsubtractor.apply(testImg); | ||
expect(fgMask).instanceOf(cv.Mat); | ||
assertMetaData(fgMask)(testImg.rows, testImg.cols, cv.CV_8U); | ||
}); | ||
|
||
it('can be called with learningRate', () => { | ||
const bgsubtractor = new cv.BackgroundSubtractorMOG2(); | ||
const fgMask = bgsubtractor.apply(testImg, learningRate); | ||
expect(fgMask).instanceOf(cv.Mat); | ||
assertMetaData(fgMask)(testImg.rows, testImg.cols, cv.CV_8U); | ||
}); | ||
}); | ||
}); | ||
}; |
Oops, something went wrong.