zoukankan      html  css  js  c++  java
  • 搭建opencv javaweb项目

    搭建opencv javaweb项目

    用到的技术maven、git、ssm、opencv、javaweb

    搭建opencv javaweb项目时,踩了很多坑;怀疑过spring,想过python,最后竟然一不小心成了,what.......闲话不多说,让我们看看这关键的一条命令

    即把opencv jar包放到maven本地仓库中
    mvn install:install-file -Dfile="G:opencvopencvuildjavaopencv-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

  • 相关阅读:
    angular2 UT 导入 jquery问题解决
    css超过指定宽度用...表示
    karma-coverage通过浏览器显示
    angular2复选框及其按钮
    前端分页控制
    input复选框checkbox默认样式纯css修改
    弧形侧边栏
    浅谈软件测试
    随笔1
    java注解小记
  • 原文地址:https://www.cnblogs.com/qjmnong/p/10067314.html
Copyright © 2011-2022 走看看