dengsixing hace 3 meses
padre
commit
80b5571af8

+ 2 - 2
4dkankan-utils-model/src/main/java/com/fdkankan/model/utils/CreateObjUtil.java

@@ -101,7 +101,7 @@ public class CreateObjUtil {
 
 	public static void killMainLoader(){
 		log.info("开始杀掉算法进程");
-		String command = "ps -ef | grep 'MainLoader.exe' | grep -v grep | awk '{print $2}' | xargs kill -9";
+		String command = "sudo ps -ef | grep 'MainLoader.exe' | grep -v grep | awk '{print $2}' | xargs kill -9";
 		callshell(command);
 		log.info("开始杀掉算法完毕");
 	}
@@ -355,7 +355,7 @@ public class CreateObjUtil {
 //		convertVisionmodeldataToTxt("D:\\test\\test\\vision.modeldata", "D:\\test\\test\\vision.txt");
 //		FileUtil.del("D:\\test\\test");
 
-		convertTxtToVisionmodeldata("D:\\test\\vision_100(1).txt", "D:\\test\\vision_100.modeldata");
+		convertTxtToVisionmodeldata("D:\\test\\vision.txt", "D:\\test\\vision.modeldata");
 
 	}
 

+ 100 - 0
4dkankan-utils-model/src/main/java/com/fdkankan/model/utils/Yingzhang.java

@@ -0,0 +1,100 @@
+package com.fdkankan.model.utils;
+
+import javax.imageio.ImageIO;
+import javax.swing.*;
+import java.awt.*;
+import java.awt.image.BufferedImage;
+import java.io.File;
+import java.io.IOException;
+
+public class Yingzhang {
+
+    public static void main(String...args) {
+        File file = new File("D:\\test\\yinzhang");
+        if (file.exists()) {
+            File[] images = file.listFiles();//f -> f.getName().toLowerCase().indexOf(".bmp") != 0
+            assert images != null;
+            for (File image : images) {
+                convertImage(image);
+            }
+        }
+        //convertImage(new File("C:/Users/Administrator/Desktop/love.bmp"));
+    }
+
+
+    /**
+     * 将图片白色部分透明化处理,只保留非白色部分
+     * @param imageFile 图片文件
+     */
+    public static void convertImage(File imageFile) {
+        if (imageFile == null || imageFile.isDirectory()) {
+            return;
+        }
+        //获取image buffered
+        BufferedImage image = null;
+        try {
+            image = ImageIO.read(imageFile);
+        } catch (IOException e) {
+            e.printStackTrace();
+        }
+        assert image != null;
+        //获取图片高度
+        int height = image.getHeight();
+        //获取图片宽度
+        int width = image.getWidth();
+        //生成ImageIcon对象
+        ImageIcon imageIcon = new ImageIcon(image);
+        //载入原图片数据
+        BufferedImage bufferedImage = new BufferedImage(width, height, BufferedImage.TYPE_4BYTE_ABGR);
+        //创建画笔对象
+        Graphics2D graphics2D = (Graphics2D) bufferedImage.getGraphics();
+        //绘制Image图片
+        graphics2D.drawImage(imageIcon.getImage(), 0, 0, null);
+        //图片透明度
+        int alpha = 0;
+        //遍历图片y坐标
+        for (int y = bufferedImage.getMinY(); y < bufferedImage.getHeight(); y++) {
+            //遍历图片x坐标
+            for (int x = bufferedImage.getMinX(); x < bufferedImage.getWidth(); x++) {
+                int rgb = bufferedImage.getRGB(x, y);
+                alpha = includeColor(rgb) ? 0 : 255;
+                rgb = (alpha << 24) | (rgb & 0X00FFFFFF);
+                bufferedImage.setRGB(x, y, rgb);
+            }
+        }
+        //将处理后的色块buffered对象写入缓冲区
+        graphics2D.drawImage(bufferedImage, 0, 0, null);
+        //创建输出路径
+        File outFile = new File(imageFile.getParentFile().getPath() + "/temp/");
+        //检测输出路径是否存在
+        boolean exists = outFile.exists() || outFile.mkdir();
+        if (exists) {
+            //获取文件名不含后缀
+            String fileName = imageFile.getName().substring(0, imageFile.getName().lastIndexOf("."));
+            //创建输出图片文件对象
+            File outImageFile = new File(outFile.getPath() + "/" + fileName + ".png");
+            try {
+                //输出图片
+                ImageIO.write(bufferedImage, "png", outImageFile);
+            } catch (IOException e) {
+                throw new RuntimeException(e);
+            }
+            //输出
+            System.out.println(outImageFile.getPath() + " 转换完成!");
+        }
+    }
+
+    /**
+     * 判断当前色块是否属于设定值的范围
+     * @param color 当前颜色
+     * @return false|true
+     */
+    public static boolean includeColor(int color) {
+        int red = (color & 0xFF0000) >> 16;
+        int green = (color & 0x00FF00) >> 8;
+        int blue = (color & 0x0000FF);
+        int color_range = 215;
+        return (red >= color_range && green >= color_range && blue >= color_range);
+    }
+
+}

+ 2 - 2
pom.xml

@@ -205,12 +205,12 @@
     <distributionManagement>
         <repository>
             <!-- 这里的ID要和setting的id一致 -->
-            <id>fdkk-releases</id>
+            <id>releases</id>
             <url>http://192.168.0.115:8081/nexus-2.14.2-01/content/repositories/releases/</url>
         </repository>
         <!--这是打成快照版本的配置 -->
         <snapshotRepository>
-            <id>fdkk-snapshots</id>
+            <id>snapshots</id>
             <url>http://192.168.0.115:8081/nexus-2.14.2-01/content/repositories/snapshots/</url>
         </snapshotRepository>
     </distributionManagement>