|
|
@@ -3,13 +3,13 @@
|
|
|
const { Controller } = require('ee-core');
|
|
|
const Log = require('ee-core/log');
|
|
|
const { dialog } = require('electron');
|
|
|
-const { checkSelectImages } = require('../api/imageMatting')
|
|
|
+const { checkSelectImages,segmentImages } = require('../api/imageMatting')
|
|
|
|
|
|
/**
|
|
|
* example
|
|
|
* @class
|
|
|
*/
|
|
|
-class ExampleController extends Controller {
|
|
|
+class ImageMattingController extends Controller {
|
|
|
|
|
|
constructor(ctx) {
|
|
|
super(ctx);
|
|
|
@@ -25,11 +25,11 @@ class ExampleController extends Controller {
|
|
|
/**
|
|
|
* upload
|
|
|
*/
|
|
|
- async upload (param) {
|
|
|
+ async upload (params) {
|
|
|
// const result = await Services.get('example').test('electron');
|
|
|
|
|
|
let dialogParams = {}
|
|
|
- if(param === 'file'){
|
|
|
+ if(params.path_type === 0){
|
|
|
dialogParams = {
|
|
|
title:"选择图片",
|
|
|
properties: ['openFile'], filters: [
|
|
|
@@ -43,19 +43,54 @@ class ExampleController extends Controller {
|
|
|
}
|
|
|
|
|
|
}
|
|
|
- const filePaths = dialog.showOpenDialogSync(dialogParams);
|
|
|
+ const filePaths = dialog.showOpenDialogSync(dialogParams)
|
|
|
+ if(!filePaths[0]){
|
|
|
+ return false;
|
|
|
+ }
|
|
|
Log.info(filePaths);
|
|
|
+ Log.info({
|
|
|
+ path_type: params.path_type, // path_type 地址类型;0图像;1目录
|
|
|
+ path: filePaths[0]
|
|
|
+ }
|
|
|
+ );
|
|
|
+
|
|
|
+ let selectParams = {
|
|
|
+ path_type:params.path_type , // path_type 地址类型;0图像;1目录
|
|
|
+ path:filePaths[0]
|
|
|
+ }
|
|
|
+
|
|
|
+ if(params.path_type === 0){
|
|
|
+ selectParams = {
|
|
|
+ path_type:params.path_type , // path_type 地址类型;0图像;1目录
|
|
|
+ image_list:filePaths
|
|
|
+ }
|
|
|
+ }
|
|
|
|
|
|
- const res = await checkSelectImages({
|
|
|
- path_type:1,
|
|
|
- path:filePaths[0],
|
|
|
- })
|
|
|
+ const res = await checkSelectImages(selectParams)
|
|
|
|
|
|
- Log.info(res);
|
|
|
- return 'hello upload';
|
|
|
+
|
|
|
+ Log.info(res.data);
|
|
|
+ if( res.data){
|
|
|
+ if( res.data.code === 0 && res.data.data){
|
|
|
+ const img = await segmentImages({
|
|
|
+ "token": params.token,
|
|
|
+ "image_type": params.image_type, //图像类型;0非服装;1服装
|
|
|
+ "segment_type": params.segment_type, //抠图精细度;0普通;1精细
|
|
|
+ "output_type": params.output_type, //出图模式 ;0透明;1白底
|
|
|
+ "need_cutout_images": res.data.data
|
|
|
+ })
|
|
|
+ if(img.data){
|
|
|
+ return img.data
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+ return res.data
|
|
|
+
|
|
|
+ }
|
|
|
+ return false;
|
|
|
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-ExampleController.toString = () => '[class ExampleController]';
|
|
|
-module.exports = ExampleController;
|
|
|
+ImageMattingController.toString = () => '[class ExampleController]';
|
|
|
+module.exports = ImageMattingController;
|