@koala123/aoi-db 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,152 @@
1
+ import { FeatureDto, FeatureRes, QueryRes, IdTypeDto, CoreLearnDto, CropSamplesDto, FeatureExtractDto, FeatureExtractRes, SampleDto, SampleFeatureDto } from "./app.dto";
2
+ export interface KLConfig {
3
+ /** dllPath;默认值:D:/kl-storage/dll/ */
4
+ dllPath: string;
5
+ /** db路径;默认值:D:/kl-storage/gallery/db/ */
6
+ dbPath: string;
7
+ /** 引擎宽;默认值:5120 */
8
+ width: number;
9
+ /** 引擎高;默认值:5120 */
10
+ height: number;
11
+ /** 引擎通道;默认值:3 */
12
+ channel: number;
13
+ /** 特征维度;默认值:384 */
14
+ featureDIM: number;
15
+ /** 特征小图高;默认值:256 */
16
+ featureWidth: number;
17
+ /** 特征小图宽;默认值:256 */
18
+ featureHeight: number;
19
+ /** 外环切区域不能用于注册,注册无效区域(防呆区域);默认值64 */
20
+ deadproofArea: number;
21
+ }
22
+ export declare class AppService {
23
+ /** 配置项 */
24
+ private KLConfig;
25
+ /** KL工具库 */
26
+ private UtilsLib;
27
+ /** KLDB库 */
28
+ private KLDBLib;
29
+ constructor(config: Partial<KLConfig>);
30
+ /**
31
+ * defect被删除,需要同时删除其对应db文件中对应的type
32
+ */
33
+ eraseDefect(id: number): Promise<void>;
34
+ /**
35
+ * 初始化引擎
36
+ */
37
+ initEngine(): Promise<boolean>;
38
+ /**
39
+ * 销毁引擎
40
+ */
41
+ destroyEngine(): boolean;
42
+ /**
43
+ * 导出数据
44
+ * @param db
45
+ */
46
+ exportDB(db: string, exportFeature?: boolean): Promise<FeatureDto[]>;
47
+ /**
48
+ * 查找所有db
49
+ */
50
+ findAll(): Promise<string[]>;
51
+ /**
52
+ * 加载DB到内存中,不存在则创建一个新的DB
53
+ * @param db db路径;若父目录不存在,则创建失败;db目录是相对KLConfig.dbPath
54
+ * @param releaseFirst load之前是否先releaseDB
55
+ * @returns db的条目总数
56
+ */
57
+ load(db: string, releaseFirst?: boolean): Promise<number>;
58
+ /**
59
+ * 释放DB
60
+ * @param db db路径
61
+ * @returns 此操作是否成功
62
+ */
63
+ release(db: string): Promise<boolean>;
64
+ /**
65
+ * 删除db文件
66
+ * @param db db路径
67
+ * @returns 操作是否成功
68
+ */
69
+ delete(db: string): Promise<boolean>;
70
+ /**
71
+ * 插入数据
72
+ * @param db db路径
73
+ * @param data 数据列表
74
+ * @returns db的条目总数
75
+ */
76
+ insert(db: string, data: FeatureDto[]): Promise<number>;
77
+ /**
78
+ * 通过id列表删除数据
79
+ * @param db db路径
80
+ * @param ids
81
+ * @returns db的条目总数
82
+ */
83
+ eraseByIds(db: string, ids: number[]): Promise<number>;
84
+ /**
85
+ * 通过类型type删除数据
86
+ * @param db db路径
87
+ * @param type
88
+ * @returns db的条目总数
89
+ */
90
+ eraseByType(db: string, type: number): Promise<number>;
91
+ /**
92
+ * 更新db
93
+ * @param db db路径
94
+ * @param data 更新数据列表 [{id,type}]
95
+ * @returns 更新操作是否成功
96
+ */
97
+ update(db: string, data: IdTypeDto[]): Promise<number>;
98
+ /**
99
+ * 根据feature查询最近邻的type与score
100
+ * @param db db路径
101
+ * @param features
102
+ */
103
+ query(db: string, features: string[]): Promise<QueryRes>;
104
+ /**
105
+ * @TODO 接口太过复杂,算法应提供一版软件端值需提供全图buffer和提取特征的中心坐标与小图宽高即可
106
+ * 提取特征
107
+ */
108
+ featureExtract(data: FeatureExtractDto): Promise<FeatureExtractRes>;
109
+ /**
110
+ * 采集正常图像上的特征向量
111
+ * 此操作会向db写入特征数据与生成对应的sample小图
112
+ */
113
+ coreLearn(data: CoreLearnDto): Promise<FeatureRes[]>;
114
+ /**
115
+ * 裁剪sample小图
116
+ */
117
+ cropSamplesBySrc(param: CropSamplesDto): Promise<boolean>;
118
+ /**
119
+ * 裁剪sample小图
120
+ */
121
+ private cropSamples;
122
+ /**
123
+ * 删除sample小图
124
+ * @param param0
125
+ * @param db sample小图对应的db
126
+ * @param srcs sample小图地址
127
+ * @returns db的条目总数
128
+ */
129
+ eraseSamples(db: string, srcs: string[]): Promise<number>;
130
+ /**
131
+ * 移动sample小图,只能移动到同pattern
132
+ * @param db sample小图对应的db
133
+ * @param data sample小图的地址 [{src,dist}]
134
+ * @returns 是否成功
135
+ */
136
+ updateSamples(db: string, data: SampleDto[]): Promise<number>;
137
+ /**
138
+ * insertsample小图,同时添加到db
139
+ * @param db sample小图对应的db
140
+ * @param data sample小图的地址与特征 [{src,dist,feature}]
141
+ * @returns db的条目总数
142
+ */
143
+ insertSamples(db: string, data: SampleFeatureDto[]): Promise<number>;
144
+ /**
145
+ * 读图
146
+ */
147
+ private readImage;
148
+ /**
149
+ * 写图
150
+ */
151
+ private writeImage;
152
+ }
@@ -0,0 +1,441 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
19
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
20
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
21
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
22
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
23
+ };
24
+ var __importStar = (this && this.__importStar) || function (mod) {
25
+ if (mod && mod.__esModule) return mod;
26
+ var result = {};
27
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
28
+ __setModuleDefault(result, mod);
29
+ return result;
30
+ };
31
+ var __metadata = (this && this.__metadata) || function (k, v) {
32
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
33
+ };
34
+ var __param = (this && this.__param) || function (paramIndex, decorator) {
35
+ return function (target, key) { decorator(target, key, paramIndex); }
36
+ };
37
+ var __importDefault = (this && this.__importDefault) || function (mod) {
38
+ return (mod && mod.__esModule) ? mod : { "default": mod };
39
+ };
40
+ Object.defineProperty(exports, "__esModule", { value: true });
41
+ exports.AppService = void 0;
42
+ const node_util_1 = require("node:util");
43
+ const fs = __importStar(require("node:fs/promises"));
44
+ const path = __importStar(require("path"));
45
+ const kl_buffer_1 = __importDefault(require("kl-buffer"));
46
+ const common_1 = require("@nestjs/common");
47
+ const event_emitter_1 = require("@nestjs/event-emitter");
48
+ const app_library_1 = require("./app.library");
49
+ let AppService = class AppService {
50
+ constructor(config) {
51
+ this.KLConfig = Object.assign({
52
+ dllPath: 'D:/kl-storage/dll/',
53
+ dbPath: 'D:/kl-storage/gallery/db/',
54
+ width: 5120,
55
+ height: 5120,
56
+ channel: 3,
57
+ featureDIM: 384,
58
+ featureWidth: 256,
59
+ featureHeight: 256,
60
+ deadproofArea: 64,
61
+ }, config);
62
+ this.UtilsLib = (0, app_library_1.shmem)(this.KLConfig.dllPath);
63
+ this.KLDBLib = (0, app_library_1.anomaly)(this.KLConfig.dllPath);
64
+ }
65
+ /**
66
+ * defect被删除,需要同时删除其对应db文件中对应的type
67
+ */
68
+ async eraseDefect(id) {
69
+ const files = await this.findAll();
70
+ for (let i = 0; i < files.length; i++) {
71
+ await this.eraseByType(files[i], id);
72
+ }
73
+ }
74
+ /**
75
+ * 初始化引擎
76
+ */
77
+ async initEngine() {
78
+ const { dbPath, width, height, channel, featureDIM } = this.KLConfig;
79
+ const time = Date.now();
80
+ const bool = await (0, node_util_1.promisify)(this.KLDBLib.initEngine.async)(dbPath, 1, channel, height, width, featureDIM);
81
+ console.log(bool ? "初始化引擎成功" : "初始化引擎失败", `耗时:${Date.now() - time}ms`);
82
+ return bool;
83
+ }
84
+ /**
85
+ * 销毁引擎
86
+ */
87
+ destroyEngine() {
88
+ const bool = this.KLDBLib.destroyEngine();
89
+ console.log(bool ? "关闭引擎成功" : "关闭引擎失败");
90
+ return bool;
91
+ }
92
+ /**
93
+ * 导出数据
94
+ * @param db
95
+ */
96
+ async exportDB(db, exportFeature) {
97
+ if (db.slice(0, 4) === 'temp')
98
+ return Promise.reject();
99
+ try {
100
+ const dbPath = path.join(this.KLConfig.dbPath, db);
101
+ const result = await fs.readFile(dbPath);
102
+ // result: count/4 + featureDIM/4 + (id/4 + type/4 + feature/featureDIM * 4)*count
103
+ const count = result.readInt32LE(0);
104
+ const featureSize = 8 + result.readInt32LE(4) * 4;
105
+ const features = [];
106
+ for (let i = 0; i < count; i++) {
107
+ const s = 8 + featureSize * i;
108
+ features.push({
109
+ id: result.readInt32LE(s),
110
+ type: result.readInt32LE(s + 4),
111
+ feature: exportFeature ?
112
+ Buffer.from(result.buffer, s, featureSize - 8).toString('base64') : '',
113
+ });
114
+ }
115
+ return features;
116
+ }
117
+ catch (e) {
118
+ return Promise.reject(e);
119
+ }
120
+ }
121
+ /**
122
+ * 查找所有db
123
+ */
124
+ async findAll() {
125
+ try {
126
+ const files = await fs.readdir(this.KLConfig.dbPath);
127
+ return files.filter((e) => {
128
+ return e.slice(-3) === '.db' && e.slice(0, 5) != 'temp-';
129
+ });
130
+ }
131
+ catch (error) {
132
+ return Promise.reject(error);
133
+ }
134
+ }
135
+ /**
136
+ * 加载DB到内存中,不存在则创建一个新的DB
137
+ * @param db db路径;若父目录不存在,则创建失败;db目录是相对KLConfig.dbPath
138
+ * @param releaseFirst load之前是否先releaseDB
139
+ * @returns db的条目总数
140
+ */
141
+ async load(db, releaseFirst) {
142
+ if (releaseFirst)
143
+ await this.release(db);
144
+ return (0, node_util_1.promisify)(this.KLDBLib.load_DB.async)(db);
145
+ }
146
+ /**
147
+ * 释放DB
148
+ * @param db db路径
149
+ * @returns 此操作是否成功
150
+ */
151
+ async release(db) {
152
+ return (0, node_util_1.promisify)(this.KLDBLib.release_DB.async)(db);
153
+ }
154
+ /**
155
+ * 删除db文件
156
+ * @param db db路径
157
+ * @returns 操作是否成功
158
+ */
159
+ async delete(db) {
160
+ const bool = await this.release(db);
161
+ try {
162
+ const dbPath = path.join(this.KLConfig.dbPath, db);
163
+ await fs.access(dbPath);
164
+ return fs.unlink(dbPath).then(() => true);
165
+ }
166
+ catch (error) { }
167
+ return bool;
168
+ }
169
+ /**
170
+ * 插入数据
171
+ * @param db db路径
172
+ * @param data 数据列表
173
+ * @returns db的条目总数
174
+ */
175
+ async insert(db, data) {
176
+ if (!data.length)
177
+ return Promise.reject(-1);
178
+ const bufferIds = Buffer.from(Int32Array.from(data.map((e) => e.id)).buffer);
179
+ const bufferTypes = Buffer.from(Int32Array.from(data.map((e) => e.type)).buffer);
180
+ return (0, node_util_1.promisify)(this.KLDBLib.insert.async)(db, data.length, bufferIds, bufferTypes, Buffer.concat(data.map((e) => Buffer.alloc(this.KLConfig.featureDIM * 4, e.feature, "base64"))));
181
+ }
182
+ /**
183
+ * 通过id列表删除数据
184
+ * @param db db路径
185
+ * @param ids
186
+ * @returns db的条目总数
187
+ */
188
+ async eraseByIds(db, ids) {
189
+ if (!ids.length)
190
+ return Promise.reject(-1);
191
+ const bufferIds = Buffer.from(Int32Array.from(ids).buffer);
192
+ return (0, node_util_1.promisify)(this.KLDBLib.erase.async)(db, ids.length, bufferIds);
193
+ }
194
+ /**
195
+ * 通过类型type删除数据
196
+ * @param db db路径
197
+ * @param type
198
+ * @returns db的条目总数
199
+ */
200
+ async eraseByType(db, type) {
201
+ return (0, node_util_1.promisify)(this.KLDBLib.erase_type.async)(db, type);
202
+ }
203
+ /**
204
+ * 更新db
205
+ * @param db db路径
206
+ * @param data 更新数据列表 [{id,type}]
207
+ * @returns 更新操作是否成功
208
+ */
209
+ async update(db, data) {
210
+ const bufferIds = Buffer.from(Int32Array.from(data.map((e) => e.id)).buffer);
211
+ const bufferTypes = Buffer.from(Int32Array.from(data.map((e) => e.type)).buffer);
212
+ return (0, node_util_1.promisify)(this.KLDBLib.update.async)(db, data.length, bufferIds, bufferTypes, null //feature数组
213
+ );
214
+ }
215
+ /**
216
+ * 根据feature查询最近邻的type与score
217
+ * @param db db路径
218
+ * @param features
219
+ */
220
+ async query(db, features) {
221
+ if (features.length == 0) {
222
+ return {
223
+ scores: [],
224
+ ids: [],
225
+ types: [],
226
+ };
227
+ }
228
+ const length = features.length;
229
+ const newFeature = features.map((feature) => {
230
+ return Buffer.alloc(this.KLConfig.featureDIM * 4, feature, "base64");
231
+ });
232
+ const bufferFeatures = Buffer.concat(newFeature);
233
+ const bufferScores = Buffer.from(Float32Array.from(new Array(length)).buffer);
234
+ const bufferTypes = Buffer.from(Int32Array.from(new Array(length)).buffer);
235
+ const bufferIds = Buffer.from(Int32Array.from(new Array(length)).buffer);
236
+ (0, node_util_1.promisify)(this.KLDBLib.query.async)(db, length, bufferFeatures, bufferScores, bufferTypes, bufferIds);
237
+ return {
238
+ scores: Array.from(new Float32Array(bufferScores.buffer)),
239
+ ids: Array.from(new Int32Array(bufferIds.buffer)),
240
+ types: Array.from(new Int32Array(bufferTypes.buffer)),
241
+ };
242
+ }
243
+ /**
244
+ * @TODO 接口太过复杂,算法应提供一版软件端值需提供全图buffer和提取特征的中心坐标与小图宽高即可
245
+ * 提取特征
246
+ */
247
+ async featureExtract(data) {
248
+ const { src, channel, width, height, dist, x, y } = data;
249
+ // 外环切区域不能用于注册,注册无效区域(防呆区域) deadproofArea = 64
250
+ const { featureHeight: h, featureWidth: w, deadproofArea } = this.KLConfig;
251
+ if (!src || !dist)
252
+ return Promise.reject();
253
+ if (x < deadproofArea || x > width - deadproofArea || y < deadproofArea || y > height - deadproofArea) {
254
+ return Promise.reject('注册区域无效!');
255
+ }
256
+ // 因为坐标点的值必须要能被16整除,进行能被16整除的坐标计算
257
+ let leftTopX_correct = Math.floor((x - w / 2) / 16) * 16;
258
+ let leftTopY_correct = Math.floor((y - h / 2) / 16) * 16;
259
+ // 缺陷小图xy方向不能超出图片边缘
260
+ leftTopX_correct = Math.min(width - w, Math.max(0, leftTopX_correct));
261
+ leftTopY_correct = Math.min(height - h, Math.max(0, leftTopY_correct));
262
+ const buffer = await this.readImage(src, width, height, channel);
263
+ const cropBuffer = Buffer.alloc(w * h * channel);
264
+ const roi = kl_buffer_1.default.alloc(16 * 2 + 8);
265
+ // [srcROI.x, srcROI.y, srcROI.w, srcROI.h, distROI.x, distROI.y, distROI.w, distROI.h, cx/特征在小图中的位置, cy]
266
+ roi.intArray = [leftTopX_correct, leftTopY_correct, w, h, 0, 0, w, h, x - leftTopX_correct, y - leftTopY_correct];
267
+ await (0, node_util_1.promisify)(this.UtilsLib.copy.async)(buffer, height, width, roi.ptr, cropBuffer, h, w, roi.intPtr[4], channel);
268
+ const bufferFeature = Buffer.alloc(this.KLConfig.featureDIM * 4);
269
+ await (0, node_util_1.promisify)(this.KLDBLib.featureExtract.async)(cropBuffer, h, w, channel, roi.intPtr[8], bufferFeature);
270
+ await this.writeImage(dist, w, h, channel, cropBuffer, true);
271
+ return {
272
+ feature: bufferFeature.toString('base64'),
273
+ position: [x - 8, y - 8, 24, 24, leftTopX_correct, leftTopY_correct],
274
+ };
275
+ }
276
+ /**
277
+ * 采集正常图像上的特征向量
278
+ * 此操作会向db写入特征数据与生成对应的sample小图
279
+ */
280
+ async coreLearn(data) {
281
+ const KLConfig = this.KLConfig;
282
+ const { src, srcMask, width = KLConfig.width, height = KLConfig.height, channel = KLConfig.channel, db, threshold, sampleDir, normalId = 0, learnUntilNone = false, featureCount = 1024, } = data;
283
+ if (!db || !sampleDir)
284
+ return;
285
+ await this.load(db);
286
+ const buffer = await this.readImage(src, width, height, channel);
287
+ let bufferMask = null;
288
+ if (srcMask)
289
+ bufferMask = await this.readImage(srcMask, width, height, 1);
290
+ // 提取的特征
291
+ const features = [];
292
+ const bufferFeatures = kl_buffer_1.default.alloc(featureCount * 3 * 4);
293
+ let num;
294
+ do {
295
+ num = await (0, node_util_1.promisify)(this.KLDBLib.coreLearn.async)(db, buffer, bufferMask, height, width, channel, normalId, featureCount, threshold, bufferFeatures.buffer);
296
+ const arr = bufferFeatures.intArray;
297
+ for (let i = 0; i < num; i++) {
298
+ features.push({ id: arr[3 * i], x: arr[3 * i + 1], y: arr[3 * i + 2] });
299
+ }
300
+ } while (learnUntilNone && num === featureCount);
301
+ this.cropSamples(buffer, width, height, channel, sampleDir, features);
302
+ return features;
303
+ }
304
+ /**
305
+ * 裁剪sample小图
306
+ */
307
+ async cropSamplesBySrc(param) {
308
+ const { src, channel, width, height, sampleDir, data } = param;
309
+ if (!src || !sampleDir || !data.length)
310
+ return false;
311
+ const buffer = await this.readImage(src, width, height, channel);
312
+ await this.cropSamples(buffer, width, height, channel, sampleDir, data);
313
+ return true;
314
+ }
315
+ /**
316
+ * 裁剪sample小图
317
+ */
318
+ async cropSamples(buffer, width, height, channel, sampleDir, data) {
319
+ if (!data.length)
320
+ return data;
321
+ const { featureHeight: w, featureWidth: h } = this.KLConfig;
322
+ const distROI = kl_buffer_1.default.alloc(16);
323
+ distROI.intArray = [0, 0, w, h];
324
+ sampleDir = path.normalize(sampleDir + '/');
325
+ await fs.mkdir(sampleDir, { recursive: true });
326
+ for (let i = 0, item; item = data[i]; i++) {
327
+ const cropBuffer = Buffer.alloc(w * h * channel);
328
+ const srcROI = kl_buffer_1.default.alloc(16);
329
+ srcROI.intArray = [item.x, item.y, w, h];
330
+ (0, node_util_1.promisify)(this.UtilsLib.copy.async)(buffer, height, width, srcROI.ptr, cropBuffer, h, w, distROI.ptr, channel);
331
+ this.writeImage(sampleDir + item.id + ".png", w, h, channel, cropBuffer);
332
+ }
333
+ return data;
334
+ }
335
+ /**
336
+ * 删除sample小图
337
+ * @param param0
338
+ * @param db sample小图对应的db
339
+ * @param srcs sample小图地址
340
+ * @returns db的条目总数
341
+ */
342
+ async eraseSamples(db, srcs) {
343
+ if (!db || !srcs.length)
344
+ return Promise.reject(-1);
345
+ // 先删数据再删图
346
+ const ids = srcs.map(e => parseInt(path.extname(e)) || 0);
347
+ const count = await this.eraseByIds(db, ids);
348
+ for (const src of srcs) {
349
+ try {
350
+ await fs.unlink(src);
351
+ }
352
+ catch (e) { }
353
+ }
354
+ return count;
355
+ }
356
+ /**
357
+ * 移动sample小图,只能移动到同pattern
358
+ * @param db sample小图对应的db
359
+ * @param data sample小图的地址 [{src,dist}]
360
+ * @returns 是否成功
361
+ */
362
+ async updateSamples(db, data) {
363
+ if (!db || !data.length)
364
+ return Promise.reject(-1);
365
+ const updateData = [];
366
+ for (let i = 0; i < data.length; i++) {
367
+ const { src, dist } = data[i];
368
+ const dirname = path.dirname(dist);
369
+ try {
370
+ await fs.mkdir(dirname, { recursive: true });
371
+ await fs.rename(src, dist);
372
+ updateData.push({
373
+ id: parseInt(path.basename(dist)),
374
+ type: parseInt(path.basename(dirname)),
375
+ });
376
+ }
377
+ catch (e) {
378
+ // console.log(e)
379
+ }
380
+ }
381
+ return this.update(db, updateData);
382
+ }
383
+ /**
384
+ * insertsample小图,同时添加到db
385
+ * @param db sample小图对应的db
386
+ * @param data sample小图的地址与特征 [{src,dist,feature}]
387
+ * @returns db的条目总数
388
+ */
389
+ async insertSamples(db, data) {
390
+ if (!db || !data.length)
391
+ return Promise.reject(-1);
392
+ const insertData = [];
393
+ for (let i = 0; i < data.length; i++) {
394
+ const { src, dist, feature } = data[i];
395
+ const dirname = path.dirname(dist);
396
+ try {
397
+ await fs.mkdir(dirname, { recursive: true });
398
+ await fs.copyFile(src, dist);
399
+ insertData.push({
400
+ id: parseInt(path.basename(dist)),
401
+ type: parseInt(path.basename(dirname)),
402
+ feature,
403
+ });
404
+ }
405
+ catch (e) {
406
+ console.log(e);
407
+ }
408
+ }
409
+ return this.insert(db, insertData);
410
+ }
411
+ /**
412
+ * 读图
413
+ */
414
+ async readImage(src, width, height, channel, buffer) {
415
+ if (!buffer)
416
+ buffer = Buffer.alloc(width * height * channel);
417
+ await (0, node_util_1.promisify)(this.UtilsLib.imread.async)(src, buffer, height, width, channel, true);
418
+ return buffer;
419
+ }
420
+ /**
421
+ * 写图
422
+ */
423
+ async writeImage(src, width, height, channel, buffer, mkdir) {
424
+ if (mkdir)
425
+ await fs.mkdir(path.dirname(src), { recursive: true });
426
+ return (0, node_util_1.promisify)(this.UtilsLib.imwrite.async)(src, buffer, height, width, channel, true);
427
+ }
428
+ };
429
+ exports.AppService = AppService;
430
+ __decorate([
431
+ (0, event_emitter_1.OnEvent)('defect.erase'),
432
+ __metadata("design:type", Function),
433
+ __metadata("design:paramtypes", [Number]),
434
+ __metadata("design:returntype", Promise)
435
+ ], AppService.prototype, "eraseDefect", null);
436
+ exports.AppService = AppService = __decorate([
437
+ (0, common_1.Injectable)(),
438
+ __param(0, (0, common_1.Inject)('CONFIG_OPTIONS')),
439
+ __metadata("design:paramtypes", [Object])
440
+ ], AppService);
441
+ //# sourceMappingURL=app.service.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"app.service.js","sourceRoot":"","sources":["../src/app.service.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AACA,yCAAsC;AACtC,qDAAuC;AACvC,2CAA6B;AAC7B,0DAAiC;AACjC,2CAAoD;AACpD,yDAAgD;AAChD,+CAA+C;AA8BxC,IAAM,UAAU,GAAhB,MAAM,UAAU;IAOrB,YAC4B,MAAyB;QAEnD,IAAI,CAAC,QAAQ,GAAG,MAAM,CAAC,MAAM,CAAC;YAC5B,OAAO,EAAE,oBAAoB;YAC7B,MAAM,EAAE,2BAA2B;YACnC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OAAO,IAAA,qBAAS,EAAC,IAAI,CAAC,QAAQ,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,GAAG,EAAE,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,OAAO,EAAE,IAAI,CAAC,CAAC;IAC3F,CAAC;CAEF,CAAA;AA1bY,gCAAU;AA6Bf;IADL,IAAA,uBAAO,EAAC,cAAc,CAAC;;;;6CAMvB;qBAlCU,UAAU;IADtB,IAAA,mBAAU,GAAE;IASR,WAAA,IAAA,eAAM,EAAC,gBAAgB,CAAC,CAAA;;GARhB,UAAU,CA0btB"}
package/dist/main.d.ts ADDED
@@ -0,0 +1 @@
1
+ export {};
package/dist/main.js ADDED
@@ -0,0 +1,33 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const core_1 = require("@nestjs/core");
4
+ const swagger_1 = require("@nestjs/swagger");
5
+ const app_module_1 = require("./app.module");
6
+ async function bootstrap() {
7
+ const app = await core_1.NestFactory.create(app_module_1.AppModule.forRoot());
8
+ const config = new swagger_1.DocumentBuilder()
9
+ .setTitle('AOI Server')
10
+ .setDescription('The AOI Server API description')
11
+ .setVersion('1.0')
12
+ .addServer('/api')
13
+ .build();
14
+ const document = swagger_1.SwaggerModule.createDocument(app, config);
15
+ swagger_1.SwaggerModule.setup('api', app, document);
16
+ app.enableCors();
17
+ app.setGlobalPrefix('/api');
18
+ const aoiDBService = app.get(app_module_1.AOIDBService);
19
+ process.on("SIGTERM", async () => {
20
+ console.log("Received SIGTERM signal. Shutting down gracefully...");
21
+ aoiDBService.destroyEngine();
22
+ process.exit(0);
23
+ });
24
+ process.on("SIGINT", async () => {
25
+ console.log("Received SIGINT signal. Shutting down gracefully...");
26
+ aoiDBService.destroyEngine();
27
+ process.exit(0);
28
+ });
29
+ aoiDBService.initEngine();
30
+ await app.listen(3000);
31
+ }
32
+ bootstrap();
33
+ //# sourceMappingURL=main.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"main.js","sourceR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