diff --git a/javacv/pom.xml b/javacv/pom.xml index a2d8496..14f579a 100644 --- a/javacv/pom.xml +++ b/javacv/pom.xml @@ -8,30 +8,83 @@ 1.0-SNAPSHOT 4.0.0 - javacv - - 11 - 11 + 1.8 + 1.8 + 1.5.9 + windows-x86_64 + linux-x86_64 - - - org.opencv - opencv-480 - 1.0.0 - + + + + + + + + + + + org.bytedeco javacv - 1.5.9 + ${javacv.version} org.bytedeco - javacv-platform - 1.5.9 + javacpp-platform + ${javacv.version} + + + org.bytedeco + ffmpeg + 6.0-${javacv.version} + ${system.windowsx64} + + + org.bytedeco + ffmpeg + 6.0-${javacv.version} + ${system.linuxx64} + + + commons-io + commons-io + 2.13.0 + + + + + + maven-assembly-plugin + + + + com.wyl.javacv.JavaCvTest + + + + jar-with-dependencies + + + + + + make-assembly + package + + single + + + + + + + \ No newline at end of file diff --git a/javacv/src/main/java/com/wyl/javacv/ImageToVideoConverter.java b/javacv/src/main/java/com/wyl/javacv/ImageToVideoConverter.java index d1bb613..69c6856 100644 --- a/javacv/src/main/java/com/wyl/javacv/ImageToVideoConverter.java +++ b/javacv/src/main/java/com/wyl/javacv/ImageToVideoConverter.java @@ -1,58 +1,59 @@ -package com.wyl.javacv; - -import org.opencv.core.Mat; -import org.opencv.core.MatOfByte; -import org.opencv.core.Size; -import org.opencv.imgcodecs.Imgcodecs; -import org.opencv.videoio.VideoWriter; - -import java.io.File; -import java.io.FileInputStream; -import java.io.IOException; -import java.io.InputStream; -import java.net.URL; - -public class ImageToVideoConverter { - public static void main(String[] args) throws IOException { - URL url = ClassLoader.getSystemResource("opencv_java480.dll"); - System.load(url.getPath()); - String imageFolderPath = "C:\\Users\\95981\\Desktop\\picture"; // 你的图片文件夹路径 - String outputVideoPath = "C:\\Users\\95981\\Desktop\\vidoe\\video14.mp4"; // 输出视频文件路径 - - try { - Size frameSize = new Size(910, 910); // 设置视频帧的大小(根据你的图片大小进行调整) - int fps = 15; // 视频帧率 - int x = VideoWriter.fourcc('D', 'I', 'V', 'X'); - VideoWriter videoWriter = new VideoWriter(outputVideoPath, x, fps, frameSize, true); - - // 获取图片文件列表 - File imageFolder = new File(imageFolderPath); - File[] imageFiles = imageFolder.listFiles(); - - if (imageFiles != null) { - for (File imageFile : imageFiles) { - if (imageFile.isFile()) { -// Mat image = Imgcodecs.imread(imageFile.getAbsolutePath()); - InputStream fos = new FileInputStream(imageFile); - Mat image = Imgcodecs.imdecode(new MatOfByte(fos.readAllBytes()), Imgcodecs.IMREAD_COLOR); - if (!image.empty()) { - // 调整图片大小,以适应视频帧大小(可选,如果图片与视频帧大小相同,可省略) -// Imgproc.resize(image, image, frameSize); - - videoWriter.write(image); - image.release(); - } - } - } - videoWriter.release(); // 释放VideoWriter资源 - System.out.println("Video created successfully!"); - } else { - System.out.println("No image files found in the folder."); - } - } catch (Exception e) { - File file = new File(outputVideoPath); - file.deleteOnExit(); - } - - } -} +//package com.wyl.javacv; +// +//import org.apache.commons.io.IOUtils; +//import org.opencv.core.Core; +//import org.opencv.core.Mat; +//import org.opencv.core.MatOfByte; +//import org.opencv.core.Size; +//import org.opencv.imgcodecs.Imgcodecs; +//import org.opencv.videoio.VideoWriter; +// +//import java.io.File; +//import java.io.FileInputStream; +//import java.io.IOException; +//import java.io.InputStream; +// +//public class ImageToVideoConverter { +// public static void main(String[] args) throws IOException { +// System.loadLibrary(Core.NATIVE_LIBRARY_NAME); +// String imageFolderPath = "/home/wyl/project/aos/opencv/picture"; // 你的图片文件夹路径 +//// String imageFolderPath = "E:\\桌面\\picture"; +// String outputVideoPath = "video14.mp4"; // 输出视频文件路径 +//// String outputVideoPath = "F:\\test\\video14.mp4"; // 输出视频文件路径 +// try { +// Size frameSize = new Size(910, 910); // 设置视频帧的大小(根据你的图片大小进行调整) +// int fps = 15; // 视频帧率 +// int x = VideoWriter.fourcc('D', 'I', 'V', 'X'); +// VideoWriter videoWriter = new VideoWriter(outputVideoPath, x, fps, frameSize, true); +// // 获取图片文件列表 +// File imageFolder = new File(imageFolderPath); +// File[] imageFiles = imageFolder.listFiles(); +// +// if (imageFiles != null) { +// for (File imageFile : imageFiles) { +// if (imageFile.isFile()) { +//// System.out.println(imageFile.getAbsolutePath()); +//// Mat image = Imgcodecs.imread(imageFile.getAbsolutePath()); +// InputStream fos = new FileInputStream(imageFile); +// Mat image = Imgcodecs.imdecode(new MatOfByte(IOUtils.toByteArray(fos)), Imgcodecs.IMREAD_COLOR); +// if (!image.empty()) { +// // 调整图片大小,以适应视频帧大小(可选,如果图片与视频帧大小相同,可省略) +//// Imgproc.resize(image, image, frameSize); +// videoWriter.write(image); +// image.release(); +// } +// } +// } +// videoWriter.release(); // 释放VideoWriter资源 +// System.out.println("Video created successfully!"); +// } else { +// System.out.println("No image files found in the folder."); +// } +// } catch (Exception e) { +// File file = new File(outputVideoPath); +// file.deleteOnExit(); +// e.printStackTrace(); +// } +// +// } +//} diff --git a/javacv/src/main/java/com/wyl/javacv/JavaCvTest.java b/javacv/src/main/java/com/wyl/javacv/JavaCvTest.java index 9053e51..7b7cbe2 100644 --- a/javacv/src/main/java/com/wyl/javacv/JavaCvTest.java +++ b/javacv/src/main/java/com/wyl/javacv/JavaCvTest.java @@ -1,5 +1,6 @@ package com.wyl.javacv; +import org.apache.commons.io.IOUtils; import org.bytedeco.ffmpeg.global.avcodec; import org.bytedeco.ffmpeg.global.avutil; import org.bytedeco.javacv.FFmpegFrameRecorder; @@ -17,9 +18,11 @@ public class JavaCvTest { public static void main(String[] args) throws Exception { //合成的MP4 存放的地址路径 这里的路径并不会自动创建,需要手动提前创建好,否则会报错:Could not open 'null' - String mp4SavePath = "C:\\Users\\95981\\Desktop\\vidoe\\img2.mp4"; + String mp4SavePath = "E:\\桌面\\vidoe\\img2.mp4"; +// String img = "/home/wyl/project/aos/opencv/picture"; +// String mp4SavePath = "/home/wyl/project/aos/opencv/video/video14.mp4"; // 输出视频文件路径 //图片存放的地址路径 - String img = "C:\\Users\\95981\\Desktop\\picture"; + String img = "E:\\桌面\\picture"; int width = 910; int height = 910; //读取所有图片 @@ -37,20 +40,17 @@ public class JavaCvTest { private static void createMp4(String mp4SavePath, Map imgMap, int width, int height) throws FrameRecorder.Exception { //视频宽高最好是按照常见的视频的宽高 16:9 或者 9:16 FFmpegFrameRecorder recorder = new FFmpegFrameRecorder(mp4SavePath, width, height); - int bitrate = 1000000; //设置视频编码层模式 import org.bytedeco.ffmpeg.global.avcodec;可能需要手动复制添加 recorder.setVideoCodec(avcodec.AV_CODEC_ID_H264); //设置视频为25帧每秒 recorder.setFrameRate(15); //设置视频图像数据格式 import org.bytedeco.ffmpeg.global.avutil;可能需要手动复制添加 recorder.setPixelFormat(avutil.AV_PIX_FMT_YUV420P); - recorder.setVideoBitrate(bitrate); - +// recorder.setVideoBitrate(100000000); recorder.setFormat("mp4"); try { recorder.start(); Java2DFrameConverter converter = new Java2DFrameConverter(); - //录制一个22秒的视频,22秒为自定义的一个视频时间长度,图片少则在22秒内,多则到22秒停止 imgMap.entrySet().stream().forEach(e -> { BufferedImage read = null; diff --git a/javacv/src/main/resources/OIP.jpg b/javacv/src/main/resources/OIP.jpg deleted file mode 100644 index a1957b4..0000000 Binary files a/javacv/src/main/resources/OIP.jpg and /dev/null differ diff --git a/javacv/src/main/resources/R.jpeg b/javacv/src/main/resources/R.jpeg deleted file mode 100644 index 4d785a5..0000000 Binary files a/javacv/src/main/resources/R.jpeg and /dev/null differ diff --git a/javacv/src/main/resources/example_output.jpg b/javacv/src/main/resources/example_output.jpg deleted file mode 100644 index b56b519..0000000 Binary files a/javacv/src/main/resources/example_output.jpg and /dev/null differ diff --git a/javacv/src/main/resources/opencv_java480.dll b/javacv/src/main/resources/opencv_java480.dll deleted file mode 100644 index 42f7a47..0000000 Binary files a/javacv/src/main/resources/opencv_java480.dll and /dev/null differ diff --git a/mapsturct/pom.xml b/mapsturct/pom.xml new file mode 100644 index 0000000..a76682b --- /dev/null +++ b/mapsturct/pom.xml @@ -0,0 +1,19 @@ + + + + JavaBasiceDemo + com.wyl.example + 1.0-SNAPSHOT + + 4.0.0 + + mapsturct + + + 11 + 11 + + + \ No newline at end of file diff --git a/pom.xml b/pom.xml index 687d10b..c8fa6fd 100644 --- a/pom.xml +++ b/pom.xml @@ -21,6 +21,7 @@ mqtt Socket jna + mapsturct pom diff --git a/spring-boot/spring-boot-common/pom.xml b/spring-boot/spring-boot-common/pom.xml index 969fc98..786be12 100644 --- a/spring-boot/spring-boot-common/pom.xml +++ b/spring-boot/spring-boot-common/pom.xml @@ -21,22 +21,6 @@ org.springframework.boot spring-boot-starter - - - - - - - - - - - - - com.aivfo - aivfo-kafka-spring-boot-starter - 1.0.0-SNAPSHOT - org.springframework.retry