Commit 84fdca77 by xmh

初始化

0 parents
**/**/logs/
**/**/target/
*.iml
**/**/.idea/
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.3.1.RELEASE</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<groupId>com.viontech.com</groupId>
<artifactId>VVAS-JNI</artifactId>
<version>1.0-SNAPSHOT</version>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-logging</artifactId>
</dependency>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
</dependency>
</dependencies>
<build>
<finalName>VVAS-JNI</finalName>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<configuration>
<excludes>
<exclude>application-*.properties</exclude>
</excludes>
</configuration>
</plugin>
</plugins>
</build>
</project>
\ No newline at end of file
package com.viontech.keliu;
import lombok.extern.slf4j.Slf4j;
import org.apache.tomcat.util.http.fileupload.util.Streams;
import org.springframework.boot.CommandLineRunner;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.core.io.Resource;
import org.springframework.core.io.support.PathMatchingResourcePatternResolver;
import org.springframework.core.io.support.ResourcePatternResolver;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
/**
* .
*
* @author 谢明辉
* @date 2021/3/22
*/
@SpringBootApplication
@Slf4j
public class JNIApp implements CommandLineRunner {
public static void main(String[] args) {
try {
SpringApplication.run(JNIApp.class, args);
} catch (Exception e) {
log.error("", e);
}
}
@Override
public void run(String... args) throws IOException {
log.info("系统:{}", System.getProperty("os.name"));
Resource[] resources = null;
if (System.getProperty("os.name").toLowerCase().contains("linux")) {
resources = new PathMatchingResourcePatternResolver().getResources(ResourcePatternResolver.CLASSPATH_ALL_URL_PREFIX + "lib/so/*");
} else if (System.getProperty("os.name").toLowerCase().contains("windows")) {
resources = new PathMatchingResourcePatternResolver().getResources(ResourcePatternResolver.CLASSPATH_ALL_URL_PREFIX + "lib/dll/*");
}
if (resources != null) {
for (Resource resource : resources) {
try {
String filename = resource.getFilename();
if (filename == null) {
continue;
}
String prefix = filename.substring(0, filename.lastIndexOf(".") - 1);
String suffix = filename.substring(filename.lastIndexOf("."));
File tempFile = File.createTempFile(prefix, suffix);
tempFile.deleteOnExit();
try (InputStream inputStream = resource.getInputStream(); FileOutputStream fileOutputStream = new FileOutputStream(tempFile)) {
Streams.copy(inputStream, fileOutputStream, true);
}
System.load(tempFile.getAbsolutePath());
} catch (Exception e) {
log.error("", e);
}
}
}
}
}
package com.viontech.keliu.controller;
import com.viontech.keliu.entity.HeatMapRequestEntity;
import com.viontech.keliu.jni.HeatMapUtil;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;
import java.awt.*;
/**
* .
*
* @author 谢明辉
* @date 2021/3/23
*/
@RestController
@Slf4j
public class MainController {
@PostMapping("/heatMapTransAxis")
public Point heatMapTransAxis(@RequestBody HeatMapRequestEntity entity) {
return HeatMapUtil.transAxis(entity.getCameraType(), entity.getCenterPoint(), entity.getMarginPoint(), entity.getCameraPoints(), entity.getMapPoints(), entity.getInputPoint());
}
}
package com.viontech.keliu.entity;
import lombok.Getter;
import lombok.Setter;
import lombok.ToString;
import java.awt.*;
/**
* .
*
* @author 谢明辉
* @date 2021/3/23
*/
@Getter
@Setter
@ToString
public class HeatMapRequestEntity {
private Integer cameraType;
private Point centerPoint;
private Point marginPoint;
private Point[] cameraPoints;
private Point[] mapPoints;
private Point inputPoint;
}
package com.viontech.keliu.jni;
import java.awt.*;
/**
* .
*
* @author 谢明辉
* @date 2021/3/23
*/
public class HeatMapUtil {
public static native Point transAxis(int cameraType, Point centerPoint, Point marginPoint, Point[] cameraPoints, Point[] mapPoints, Point inputPoint);
}
server.port=14040
\ No newline at end of file
/* DO NOT EDIT THIS FILE - it is machine generated */
#include <jni.h>
/* Header for class com_viontech_keliu_jni_HeatMapUtil */
#ifndef _Included_com_viontech_keliu_jni_HeatMapUtil
#define _Included_com_viontech_keliu_jni_HeatMapUtil
#ifdef __cplusplus
extern "C" {
#endif
/*
* Class: com_viontech_keliu_jni_HeatMapUtil
* Method: transAxis
* Signature: (ILjava/awt/Point;Ljava/awt/Point;[Ljava/awt/Point;[Ljava/awt/Point;Ljava/awt/Point;)Ljava/awt/Point;
*/
JNIEXPORT jobject JNICALL Java_com_viontech_keliu_jni_HeatMapUtil_transAxis
(JNIEnv *, jclass, jint, jobject, jobject, jobjectArray, jobjectArray, jobject);
#ifdef __cplusplus
}
#endif
#endif
No preview for this file type
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!