代码拉取完成,页面将自动刷新
同步操作将从 黎英明/H5人脸识别系列实例 强制同步,此操作会覆盖自 Fork 仓库以来所做的任何修改,且无法恢复!!!
确定后同步将在后台操作,完成时将刷新页面,请耐心等待。
package com.zfsoft.artificialIntelligence.faceRecognition.controller;
import java.io.ByteArrayOutputStream;
import java.io.InputStream;
import java.util.HashMap;
import java.util.Map;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.multipart.MultipartFile;
import org.springframework.web.servlet.ModelAndView;
/**
* 人脸识别服务 controller
* @author liyingming
*
*/
@Controller
@RequestMapping(value = "/faceRecognition")
public class faceRecognitionController {
/**
* 人脸检测测试页面
* @return
* @throws Exception
*/
@RequestMapping(value = "/test.do")
public ModelAndView queryVoi() throws Exception {
ModelAndView modelAndView = new ModelAndView();
modelAndView.setViewName("/artificialIntelligence/faceRecognition/test");
return modelAndView;
}
/**
* 请求人脸检测
* @return
* @throws Exception
*/
@RequestMapping(value = "/save.do")
@ResponseBody
public Map<String, Object> queryService(@RequestParam("the_file") MultipartFile file) {
Map<String, Object> modelMap = new HashMap<String, Object>();
try {
//将数据转为流
InputStream content = file.getInputStream();
ByteArrayOutputStream swapStream = new ByteArrayOutputStream();
byte[] buff = new byte[100];
int rc = 0;
while ((rc = content.read(buff, 0, 100)) > 0) {
swapStream.write(buff, 0, rc);
}
//获得二进制数组
byte[] in2b = swapStream.toByteArray();
//调用人脸检测的方法
Map<String, String> strmap = FaceDetect.detectby(in2b);
//将map数据封装json传到前台
//此处JsonUtil未提供,大家可以找一个转json的方法
//String strjson = JsonUtil.mapToJson(strmap);
modelMap.put("strjson", strjson);
modelMap.put("success", true);
} catch (Exception e) {
modelMap.put("success", false);
modelMap.put("data", e.getMessage());
}
return modelMap;
}
}
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。