| | |
| | | import com.arcsoft.face.FaceEngine; |
| | | import com.arcsoft.face.toolkit.ImageFactory; |
| | | import com.arcsoft.face.toolkit.ImageInfo; |
| | | import com.google.gson.reflect.TypeToken; |
| | | import com.whyc.constant.YamlProperties; |
| | | import com.whyc.dto.Response; |
| | | import com.whyc.factory.FaceEngineFactory; |
| | | import com.whyc.pojo.PermitGroup; |
| | | import com.whyc.pojo.UserFace; |
| | | import com.whyc.pojo.UserInf; |
| | | import com.whyc.service.FaceService; |
| | | import com.whyc.service.PermitGroupUserService; |
| | |
| | | import com.whyc.util.FaceIdentifyUtil; |
| | | import io.swagger.annotations.Api; |
| | | import io.swagger.annotations.ApiOperation; |
| | | import org.assertj.core.util.Arrays; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | import org.springframework.web.bind.annotation.*; |
| | | import sun.misc.BASE64Decoder; |
| | |
| | | import java.io.File; |
| | | import java.io.FileOutputStream; |
| | | import java.io.IOException; |
| | | import java.util.HashMap; |
| | | import java.util.List; |
| | | |
| | | import static com.whyc.util.ActionUtil.getApplication; |
| | |
| | | */ |
| | | @RequestMapping("face") |
| | | @RestController |
| | | @Api(tags = "人脸识别") |
| | | @Api(tags = "用户管理-人脸识别") |
| | | public class FaceController { |
| | | |
| | | @Resource |
| | |
| | | /*=========图片保存===========*/ |
| | | //获取到tomcat webapp绝对路径 |
| | | String realPath = getApplication().getRealPath("/"); |
| | | // String[] split = realPath.split(File.separator); |
| | | String[] split = realPath.split("\\\\"); |
| | | String[] split = realPath.split(File.separator); |
| | | //String[] split = realPath.split("\\\\"); |
| | | String projectName = split[split.length - 1]; |
| | | |
| | | String webAppPath = realPath.substring(0, realPath.lastIndexOf(projectName)); |
| | |
| | | /**获取图片文件夹全路径*/ |
| | | private String findFileDirPath() { |
| | | String realPath = getApplication().getRealPath("/"); |
| | | String[] split = realPath.split("\\\\"); |
| | | //String[] split = realPath.split("\\\\"); |
| | | String[] split = realPath.split(File.separator); |
| | | String projectName = split[split.length - 1]; |
| | | |
| | | String webAppPath = realPath.substring(0, realPath.lastIndexOf(projectName)); |
| | | |
| | | //存储人脸图片的文件夹 |
| | | String fileDirName = webAppPath + "\\" + projectName + "_photo"; |
| | | //String fileDirName = webAppPath + "\\" + projectName + "_photo"; |
| | | String fileDirName = webAppPath + File.separator + projectName + "_photo"; |
| | | |
| | | return fileDirName; |
| | | } |
| | |
| | | HttpServletRequest request = ActionUtil.getRequest(); |
| | | //获取项目名称 |
| | | String realPath = ActionUtil.getApplication().getRealPath("/"); |
| | | String[] split = realPath.split("/"); |
| | | //String[] split = realPath.split("/"); |
| | | String[] split = realPath.split(File.separator); |
| | | String projectName = split[split.length - 1]; |
| | | //图片保存路径,采取ip+port访问形式而非硬盘形式,方便图片加载 |
| | | String url = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+"/"+projectName+"_photo/"+uName+".jpg"; |