搭建opencv javaweb项目
2024-08-26 16:55:15
搭建opencv javaweb项目
用到的技术maven、git、ssm、opencv、javaweb
搭建opencv javaweb项目时,踩了很多坑;怀疑过spring,想过python,最后竟然一不小心成了,what.......闲话不多说,让我们看看这关键的一条命令
即把opencv jar包放到maven本地仓库中
mvn install:install-file -Dfile="G:\opencv\opencv\build\java\opencv-341.jar" -DgroupId=org.opencv -DartifactId=opencv -Dversion=3.4.1 -Dpackaging=jar
再看看一直报'javaClassNotDefound'的maven依赖配置
<dependency>
<groupId>org.opencv</groupId>
<artifactId>opencv</artifactId>
<version>3.4.1</version>
<systemPath>G:/opencv/opencv/build/java/opencv-341.jar</systemPath>
<scope>system</scope>
</dependency>
再看看不报错的配置
<dependency>
<groupId>org.opencv</groupId>
<artifactId>opencv</artifactId>
<version>3.4.1</version>
</dependency>
到这离成功已经很近了,我们还需要加载dll或者so文件
我们可以在用到opencv的类中用静态代码块加载dll或者so文件,
或者配置一个监听器如下,别忘了在web.xml中配置
package cn.edu.njupt.configure;
import cn.edu.njupt.utils.OpencvConstantUtils;
import javax.servlet.ServletContextEvent;
import javax.servlet.ServletContextListener;
public class InitOpencv implements ServletContextListener {
@Override
public void contextDestroyed(ServletContextEvent servletContextEvent) {
}
public void contextInitialized(ServletContextEvent arg0) {
System.load("G:/opencv/opencv/build/java/x64/opencv_java341.dll");
}
}
web.xml
<listener>
<listener-class>cn.edu.njupt.configure.InitOpencv</listener-class>
</listener>
到此项目可以说就搭建好了,liunx,mac只需要按照上述步骤把对应文件路径替换掉就可以了
本项目地址:https://github.com/YLDarren/stitp
相关项目地址:https://github.com/YLDarren/opencvHandleImg
最新文章
- .NET基础面试题整理
- Xcode磁盘空间大清理
- codevs 1001 舒适的路线(Kruskal)
- Effective C++ -----条款34:区分接口继承和实现继承
- 云计算和大数据时代网络技术揭秘(十二)自定义网络SDN
- Android -- The Manifest File
- Apache+PHP+Mysql OS X 10.9 Mavericks WEB 服务器配置
- spring事务管理-摘抄
- mongodb,redis,mysql 简要对比
- eclipse加速
- HW6.21
- PetaPoco 快速上手
- VS2012发布网站详细步骤问题
- PHP中的面向对象思想
- 用yum快速搭建LAMP平台
- Django积木块一——验证码
- Android Studio 插件(plugins)或者intellij idea 插件(plugins)无法安装
- mysql 数据库操作 数据库的增删改查
- pytho常用模块2——random
- css字符串转换为类map对象及反转