Skip to content
This repository was archived by the owner on Mar 17, 2024. It is now read-only.

Commit bd077e7

Browse files
authored
Feature/3/update to latest interface (#5)
* (#3) Adjust to latest interface * (#3) Mock jimp package * (#3) Use npm pack result in e2e test to avoid wrong module resolution * (#3) Run pretest setup before Docker e2e tests * (#3) Run pretest setup before Docker e2e tests * (#3) Change working directory instead of using --prefix on npm to avoid path errors on install * (#3) Use dedicated install script for flexible installation * (#3) Limit Docker tests to e2e tests * (#3) Run install in build script * (#3) Use npm cit on build script * (#3) Revert using npm cit * (#3) Disable Docker E2E tests until problems have been resolved * (#3) Refined E2E setup * (#3) Fixed tests * (#3) Refined result image * (#3) Removed screen tests from plugin * (#3) Lowered matching confidence for drag & drop test * (#3) Add support for BGR and RGB color modes * (#3) Limit node version for CI runs to 16 * (#3) Limit node version for CI runs to 14
1 parent e96a7df commit bd077e7

File tree

6 files changed

+38
-30
lines changed

6 files changed

+38
-30
lines changed

.github/workflows/ci.yaml

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -37,10 +37,7 @@ jobs:
3737
strategy:
3838
matrix:
3939
os: [ ubuntu-latest, windows-latest, macos-latest ]
40-
node: [ 14, 16 ]
41-
exclude:
42-
- os: ubuntu-latest
43-
node: 14
40+
node: [ 14 ]
4441
runs-on: ${{matrix.os}}
4542
steps:
4643
- name: Set up Git repository

.github/workflows/snapshot_release.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ jobs:
1212
strategy:
1313
matrix:
1414
os: [ ubuntu-latest, windows-latest, macos-latest ]
15-
node: [ 16 ]
15+
node: [ 14 ]
1616
runs-on: ${{matrix.os}}
1717
steps:
1818
- name: Set up Git repository
@@ -48,7 +48,7 @@ jobs:
4848
- name: Set up node
4949
uses: actions/setup-node@v2
5050
with:
51-
node-version: 16
51+
node-version: 14
5252
registry-url: 'https://registry.npmjs.org'
5353
- name: Install
5454
run: npm ci

.github/workflows/tagged_release.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ jobs:
99
strategy:
1010
matrix:
1111
os: [ ubuntu-latest, windows-latest, macos-latest ]
12-
node: [ 16 ]
12+
node: [ 14 ]
1313
runs-on: ${{matrix.os}}
1414
steps:
1515
- name: Set up Git repository
@@ -45,7 +45,7 @@ jobs:
4545
- name: Set up node
4646
uses: actions/setup-node@v2
4747
with:
48-
node-version: 16
48+
node-version: 14
4949
registry-url: 'https://registry.npmjs.org'
5050
- name: Install
5151
run: npm ci

e2e/plugin-test/index.e2e.spec.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@ describe("E2E tests", () => {
7070

7171
it("drag & drop", async () => {
7272
screen.config.resourceDirectory = "./e2e/assets";
73+
screen.config.confidence = 0.94;
7374

7475
const expected = new Region(34, 574, 75, 107);
7576
const maxDiff = 1;

lib/image-processor.class.ts

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import * as cv from "opencv4nodejs-prebuilt";
2-
import {Image, Region} from "@nut-tree/nut-js";
2+
import {ColorMode, Image, Region} from "@nut-tree/nut-js";
33

44
function determineROI(img: Image, roi: Region): cv.Rect {
55
return new cv.Rect(
@@ -22,7 +22,12 @@ export const fromImageWithAlphaChannel = async (
2222
img: Image,
2323
roi?: Region,
2424
): Promise<cv.Mat> => {
25-
const mat = await new cv.Mat(img.data, img.height, img.width, cv.CV_8UC4).cvtColorAsync(cv.COLOR_BGRA2BGR);
25+
let mat: cv.Mat;
26+
if (img.colorMode === ColorMode.RGB) {
27+
mat = await new cv.Mat(img.data, img.height, img.width, cv.CV_8UC4).cvtColorAsync(cv.COLOR_RGBA2BGR);
28+
} else {
29+
mat = await new cv.Mat(img.data, img.height, img.width, cv.CV_8UC4).cvtColorAsync(cv.COLOR_BGRA2BGR);
30+
}
2631
if (roi) {
2732
return mat.getRegion(determineROI(img, roi));
2833
} else {
@@ -43,7 +48,12 @@ export const fromImageWithoutAlphaChannel = async (
4348
img: Image,
4449
roi?: Region,
4550
): Promise<cv.Mat> => {
46-
const mat = new cv.Mat(img.data, img.height, img.width, cv.CV_8UC3);
51+
let mat: cv.Mat;
52+
if (img.colorMode === ColorMode.RGB) {
53+
mat = await new cv.Mat(img.data, img.height, img.width, cv.CV_8UC3).cvtColorAsync(cv.COLOR_RGB2BGR);
54+
} else {
55+
mat = new cv.Mat(img.data, img.height, img.width, cv.CV_8UC3);
56+
}
4757
if (roi) {
4858
return mat.getRegion(determineROI(img, roi));
4959
} else {

package-lock.json

Lines changed: 19 additions & 19 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)