Skip to content
This repository was archived by the owner on Oct 18, 2023. It is now read-only.

Commit f25320d

Browse files
Merge pull request justadudewhohacks#59 from justadudewhohacks/#57fixes
some fixes for SuperpixelSLIC and SuperpixelLSC
2 parents a862a4c + 0dbc803 commit f25320d

File tree

10 files changed

+132
-9
lines changed

10 files changed

+132
-9
lines changed

cc/modules/ximgproc/SuperpixelLSC.cc

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
#ifdef HAVE_XIMGPROC
22

3-
#if OPENCV_MINOR_VERSION > 0
4-
53
#include "SuperpixelLSC.h"
64

5+
#if CV_MINOR_VERSION > 0
6+
77
Nan::Persistent<v8::FunctionTemplate> SuperpixelLSC::constructor;
88

99
NAN_MODULE_INIT(SuperpixelLSC::Init) {
@@ -35,7 +35,7 @@ NAN_METHOD(SuperpixelLSC::New) {
3535
FF_ARG_INSTANCE(0, self->img, Mat::constructor, FF_UNWRAP_MAT_AND_GET);
3636
FF_ARG_INT_IFDEF(1, self->regionSize, 10);
3737
FF_ARG_INT_IFDEF(2, self->ratio, 0.075);
38-
38+
3939
self->Wrap(info.Holder());
4040
self->superpixelLsc = cv::ximgproc::createSuperpixelLSC(
4141
self->img,

cc/modules/ximgproc/SuperpixelLSC.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
#include "Mat.h"
33
#include "macros.h"
44

5-
#if OPENCV_MINOR_VERSION > 0
5+
#if CV_MINOR_VERSION > 0
66

77
#ifndef __FF_SUPERPIXELLSC_H__
88
#define __FF_SUPERPIXELLSC_H__

cc/modules/ximgproc/SuperpixelSLIC.cc

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
#ifdef HAVE_XIMGPROC
22

3-
#if OPENCV_MINOR_VERSION > 0
4-
53
#include "SuperpixelSLIC.h"
64

5+
#if CV_MINOR_VERSION > 0
6+
77
Nan::Persistent<v8::FunctionTemplate> SuperpixelSLIC::constructor;
88

99
NAN_MODULE_INIT(SuperpixelSLIC::Init) {
@@ -34,7 +34,7 @@ NAN_METHOD(SuperpixelSLIC::New) {
3434
SuperpixelSLIC* self = new SuperpixelSLIC();
3535

3636
FF_ARG_INSTANCE(0, self->img, Mat::constructor, FF_UNWRAP_MAT_AND_GET);
37-
FF_ARG_INT(1, self->algorithm);
37+
FF_ARG_INT_IFDEF(1, self->algorithm, cv::ximgproc::SLICO);
3838
FF_ARG_INT_IFDEF(2, self->regionSize, 10);
3939
FF_ARG_INT_IFDEF(3, self->ruler, 10.0);
4040

cc/modules/ximgproc/SuperpixelSLIC.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
#include "Mat.h"
33
#include "macros.h"
44

5-
#if OPENCV_MINOR_VERSION > 0
5+
#if CV_MINOR_VERSION > 0
66

77
#ifndef __FF_SUPERPIXELSLIC_H__
88
#define __FF_SUPERPIXELSLIC_H__

cc/modules/ximgproc/ximgproc.cc

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,19 @@
22

33
#include "ximgproc.h"
44
#include "SuperpixelSEEDS.h"
5+
6+
#if CV_MINOR_VERSION > 0
57
#include "SuperpixelSLIC.h"
68
#include "SuperpixelLSC.h"
9+
#endif
710

811
NAN_MODULE_INIT(XImgproc::Init) {
912
SuperpixelSEEDS::Init(target);
10-
#if OPENCV_MINOR_VERSION > 0
13+
#if CV_MINOR_VERSION > 0
1114
SuperpixelSLIC::Init(target);
1215
SuperpixelLSC::Init(target);
16+
FF_SET_JS_PROP(target, SLIC, Nan::New<v8::Integer>(cv::ximgproc::SLIC));
17+
FF_SET_JS_PROP(target, SLICO, Nan::New<v8::Integer>(cv::ximgproc::SLICO));
1318
#endif
1419
}
1520

doc/README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -212,6 +212,10 @@ Missing some function bindings? No problem! - <a href="https://github.com/justad
212212
* <a href="./ximgproc/ximgproc.md"><b>ximgproc</b></a>
213213
* <a href="./ximgproc/SuperpixelSEEDS.md"><b>SuperpixelSEEDS</b></a>
214214
* <a href="./ximgproc/SuperpixelSEEDS.md#iterate">iterate</a>
215+
* <a href="./ximgproc/SuperpixelSLIC.md"><b>SuperpixelSLIC</b></a>
216+
* <a href="./ximgproc/SuperpixelSLIC.md#iterate">iterate</a>
217+
* <a href="./ximgproc/SuperpixelLSC.md"><b>SuperpixelLSC</b></a>
218+
* <a href="./ximgproc/SuperpixelLSC.md#iterate">iterate</a>
215219
* <a href="./objdetect/objdetect.md"><b>objdetect</b></a>
216220
* <a href="./objdetect/CascadeClassifier.md"><b>CascadeClassifier</b></a>
217221
* <a href="./objdetect/CascadeClassifier.md#detectMultiScale">detectMultiScale</a>

doc/ximgproc/SuperpixelLSC.md

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
# SuperpixelLSC
2+
3+
## Accessors
4+
``` javascript
5+
{
6+
img: Mat,
7+
labels: Mat,
8+
labelContourMask: Mat,
9+
regionSize: Int,
10+
ratio: Number,
11+
numCalculatedSuperpixels: Int
12+
}
13+
```
14+
15+
<a name="constructors"></a>
16+
17+
## Constructors
18+
``` javascript
19+
SuperpixelLSC : new SuperpixelLSC(Mat img, Int regionSize = 10, Number ratio = 10)
20+
```
21+
22+
## Methods
23+
24+
<a name="iterate"></a>
25+
26+
### iterate
27+
``` javascript
28+
lsc.iterate(Uint iterations = 10)
29+
```

doc/ximgproc/SuperpixelSEEDS.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
{
66
img: Mat,
77
labels: Mat,
8+
labelContourMask: Mat,
89
numSuperpixels: Int,
910
numLevels: Int,
1011
prior: Int,

doc/ximgproc/SuperpixelSLIC.md

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
# SuperpixelSLIC
2+
3+
## Accessors
4+
``` javascript
5+
{
6+
img: Mat,
7+
labels: Mat,
8+
labelContourMask: Mat,
9+
algorithm: Int,
10+
regionSize: Int,
11+
ruler: Number,
12+
numCalculatedSuperpixels: Int
13+
}
14+
```
15+
16+
<a name="constructors"></a>
17+
18+
## Constructors
19+
``` javascript
20+
SuperpixelSLIC : new SuperpixelSLIC(Mat img, Int algorithm = cv.SLICO, Int regionSize = 10, Number ruler = 10)
21+
```
22+
23+
## Methods
24+
25+
<a name="iterate"></a>
26+
27+
### iterate
28+
``` javascript
29+
slic.iterate(Uint iterations = 10)
30+
```

test/tests/modules/imgproc/ximgproc.test.js

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,4 +43,58 @@ describe('ximgproc', () => {
4343
});
4444
});
4545
});
46+
47+
if (cv.version.minor > 0) {
48+
describe('SuperpixelSLIC', () => {
49+
const algorithm = cv.SLICO;
50+
51+
describe('constructor', () => {
52+
funcShouldRequireArgs(() => new cv.SuperpixelSLIC());
53+
54+
it('should be constructable with required args', () => {
55+
const superpixel = new cv.SuperpixelSLIC(testImg, algorithm);
56+
expect(superpixel).to.have.property('img').instanceOf(cv.Mat);
57+
assertMetaData(testImg)(superpixel.img);
58+
assertPropsWithValue(superpixel)({
59+
algorithm
60+
});
61+
});
62+
});
63+
64+
describe('iterate', () => {
65+
it('should iterate with default values', () => {
66+
const superpixel = new cv.SuperpixelSLIC(testImg, algorithm);
67+
superpixel.iterate();
68+
assert(superpixel.numCalculatedSuperpixels > 0, 'no superpixels calculated');
69+
assertPropsWithValue(superpixel.labels)({
70+
rows: testImg.rows, cols: testImg.cols, type: cv.CV_32S
71+
});
72+
});
73+
});
74+
});
75+
76+
77+
describe('SuperpixelLSC', () => {
78+
describe('constructor', () => {
79+
funcShouldRequireArgs(() => new cv.SuperpixelLSC());
80+
81+
it('should be constructable with required args', () => {
82+
const superpixel = new cv.SuperpixelLSC(testImg);
83+
expect(superpixel).to.have.property('img').instanceOf(cv.Mat);
84+
assertMetaData(testImg)(superpixel.img);
85+
});
86+
});
87+
88+
describe('iterate', () => {
89+
it('should iterate with default values', () => {
90+
const superpixel = new cv.SuperpixelLSC(testImg);
91+
superpixel.iterate();
92+
assert(superpixel.numCalculatedSuperpixels > 0, 'no superpixels calculated');
93+
assertPropsWithValue(superpixel.labels)({
94+
rows: testImg.rows, cols: testImg.cols, type: cv.CV_32S
95+
});
96+
});
97+
});
98+
});
99+
}
46100
});

0 commit comments

Comments
 (0)