Giter VIP home page Giter VIP logo

Comments (13)

GoogleCodeExporter avatar GoogleCodeExporter commented on July 28, 2024
Hum, looks like MacPorts does not add its libraries in the path by default. We 
can work around this by setting the DYLD_FALLBACK_LIBRARY_PATH environment 
variable, e.g.:
    export DYLD_FALLBACK_LIBRARY_PATH=/opt/local/lib/
This directory will be hardcoded next time I recompile JavaCV with MacPorts, 
well unless OpenCV 2.3.2 or something comes out and MacPorts takes another few 
months to follow...

Original comment by [email protected] on 4 Nov 2011 at 4:12

  • Changed title: cannot run javacv example, ClassNotFoundException (Mac OS X)
  • Changed state: Started

from javacv.

GoogleCodeExporter avatar GoogleCodeExporter commented on July 28, 2024
Well, oddly enough now I can run the javacv example just fine in Eclipse, 
though still having some issue with the classpath on the command line.

What changed is I rebuilt libpng in Mac Ports.  I can link to the thread 
discussing it there if you wish.

Original comment by [email protected] on 4 Nov 2011 at 8:49

from javacv.

GoogleCodeExporter avatar GoogleCodeExporter commented on July 28, 2024
[deleted comment]

from javacv.

GoogleCodeExporter avatar GoogleCodeExporter commented on July 28, 2024
I got it. Thanks anyway.

Original comment by [email protected] on 22 Nov 2011 at 3:31

from javacv.

GoogleCodeExporter avatar GoogleCodeExporter commented on July 28, 2024
Mind sharing your solution?

Original comment by [email protected] on 22 Nov 2011 at 2:09

from javacv.

GoogleCodeExporter avatar GoogleCodeExporter commented on July 28, 2024
Typing the export command above in a Terminal window does not work?

Original comment by [email protected] on 26 Nov 2011 at 6:04

from javacv.

GoogleCodeExporter avatar GoogleCodeExporter commented on July 28, 2024
If you are running it in Eclipse simply add the environment variable 
DYLD_FALLBACK_LIBRARY_PATH=/opt/local/lib  in the debug/run configuration and 
that should work.  Otherwise if you run from the command line having it set in 
your env should also work.

Original comment by [email protected] on 29 Nov 2011 at 5:37

from javacv.

GoogleCodeExporter avatar GoogleCodeExporter commented on July 28, 2024
export DYLD_FALLBACK_LIBRARY_PATH=/opt/local/lib/

also worked for me.
(OSX)

Original comment by [email protected] on 2 Dec 2011 at 6:35

from javacv.

GoogleCodeExporter avatar GoogleCodeExporter commented on July 28, 2024
Fixed in latest release!

Original comment by [email protected] on 8 Jan 2012 at 3:46

  • Changed state: Fixed

from javacv.

GoogleCodeExporter avatar GoogleCodeExporter commented on July 28, 2024
hello we met the same problem,
My environment is : java 7, open cv 2.4.8, javacv 0.7

The problem below:

SEVERE: Servlet.service() for servlet [UploadServlet] in context with path 
[/ImgWeb] threw exception [Servlet execution threw an exception] with root cause
java.lang.ClassNotFoundException: com.googlecode.javacv.cpp.opencv_core$CvArr
    at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1666)
    at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1511)
    at com.matrix.servlet.UploadServlet.doPost(UploadServlet.java:43)
    at com.matrix.servlet.UploadServlet.doGet(UploadServlet.java:30)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:621)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:722)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:303)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
    at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:243)
    at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:201)
    at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:163)
    at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:108)
    at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:556)
    at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118)
    at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:401)
    at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:242)
    at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:267)
    at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:245)
    at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:260)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
    at java.lang.Thread.run(Unknown Source)


I write a function:
public static double getSimilarity(String src, String template){
        double similarity = 0.0d;
        IplImage img, tpl, res;
        CvPoint minloc = new CvPoint();
        CvPoint maxloc = new CvPoint();
        double minval[] = new double[5];
        double maxval[] = new double[5];

        int img_width, img_height;
        int tpl_width, tpl_height;
        int res_width, res_height;

        img = cvLoadImage(src, CV_LOAD_IMAGE_COLOR);//CV_LOAD_IMAGE_COLOR
        tpl = cvLoadImage(template, CV_LOAD_IMAGE_COLOR);//CV_LOAD_IMAGE_COLOR

        img_width = img.width();
        img_height = img.height();
        tpl_width = tpl.width();
        tpl_height = tpl.height();

        if (img_height < tpl_height || img_width < tpl_width) {

            System.out.println("inter");
            IplImage tempImg = img.clone();
            img = tpl.clone();
            tpl = tempImg.clone();
            cvReleaseImage(tempImg);

            res_width = tpl_width-img_width +1;
            res_height = tpl_height - img_height +1;

            System.out.println("res_width: " + res_width + "res_height: " + res_height);

        } else {
            res_width = img_width - tpl_width + 1;
            res_height = img_height - tpl_height + 1;

        }

        System.out.println("res_width: " + res_width + "res_height: " + res_height);

        res = cvCreateImage(cvSize(res_width, res_height), IPL_DEPTH_32F, 1);
        cvMatchTemplate(img, tpl, res, CV_TM_CCORR_NORMED );
        cvMinMaxLoc(res, minval, maxval, minloc, maxloc, null);

        System.out.println("min: " + minval[0]);

        CvPoint pt1;
        CvPoint pt2;
        CvRect rect;
        rect = cvRect(maxloc.x(), maxloc.y(), tpl.width(), tpl.height());// 最佳的匹配区域
        pt1 = cvPoint(rect.x(), rect.y());
        pt2 = cvPoint(rect.x() + rect.width(), rect.y() + rect.height());
        cvRectangle(img, pt1, pt2, cvScalar(0, 0, 0, 0), 1, 8, 0);

        cvNamedWindow("reference", CV_WINDOW_AUTOSIZE);
        cvShowImage("reference", img);

        cvWaitKey(0);

        similarity = maxval[0];

        /* free memory*/
        cvReleaseImage(img);
        cvReleaseImage(tpl);
        cvReleaseImage(res);

        return similarity;
    }
when I run it in the main function there is no problem, but when I invok the 
function 
in at servlet or rest service there cause a class not found exception, How can 
I solve the problem

Original comment by [email protected] on 18 Apr 2014 at 6:44

from javacv.

GoogleCodeExporter avatar GoogleCodeExporter commented on July 28, 2024
hello we met the same problem,
My environment is : java 7, open cv 2.4.8, javacv 0.7

The problem below:

SEVERE: Servlet.service() for servlet [UploadServlet] in context with path 
[/ImgWeb] threw exception [Servlet execution threw an exception] with root cause
java.lang.ClassNotFoundException: com.googlecode.javacv.cpp.opencv_core$CvArr
    at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1666)
    at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1511)
    at com.matrix.servlet.UploadServlet.doPost(UploadServlet.java:43)
    at com.matrix.servlet.UploadServlet.doGet(UploadServlet.java:30)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:621)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:722)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:303)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
    at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:243)
    at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:201)
    at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:163)
    at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:108)
    at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:556)
    at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118)
    at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:401)
    at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:242)
    at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:267)
    at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:245)
    at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:260)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
    at java.lang.Thread.run(Unknown Source)


I write a function:
public static double getSimilarity(String src, String template){
        double similarity = 0.0d;
        IplImage img, tpl, res;
        CvPoint minloc = new CvPoint();
        CvPoint maxloc = new CvPoint();
        double minval[] = new double[5];
        double maxval[] = new double[5];

        int img_width, img_height;
        int tpl_width, tpl_height;
        int res_width, res_height;

        img = cvLoadImage(src, CV_LOAD_IMAGE_COLOR);//CV_LOAD_IMAGE_COLOR
        tpl = cvLoadImage(template, CV_LOAD_IMAGE_COLOR);//CV_LOAD_IMAGE_COLOR

        img_width = img.width();
        img_height = img.height();
        tpl_width = tpl.width();
        tpl_height = tpl.height();

        if (img_height < tpl_height || img_width < tpl_width) {

            System.out.println("inter");
            IplImage tempImg = img.clone();
            img = tpl.clone();
            tpl = tempImg.clone();
            cvReleaseImage(tempImg);

            res_width = tpl_width-img_width +1;
            res_height = tpl_height - img_height +1;

            System.out.println("res_width: " + res_width + "res_height: " + res_height);

        } else {
            res_width = img_width - tpl_width + 1;
            res_height = img_height - tpl_height + 1;

        }

        System.out.println("res_width: " + res_width + "res_height: " + res_height);

        res = cvCreateImage(cvSize(res_width, res_height), IPL_DEPTH_32F, 1);
        cvMatchTemplate(img, tpl, res, CV_TM_CCORR_NORMED );
        cvMinMaxLoc(res, minval, maxval, minloc, maxloc, null);

        System.out.println("min: " + minval[0]);

        CvPoint pt1;
        CvPoint pt2;
        CvRect rect;
        rect = cvRect(maxloc.x(), maxloc.y(), tpl.width(), tpl.height());// 最佳的匹配区域
        pt1 = cvPoint(rect.x(), rect.y());
        pt2 = cvPoint(rect.x() + rect.width(), rect.y() + rect.height());
        cvRectangle(img, pt1, pt2, cvScalar(0, 0, 0, 0), 1, 8, 0);

        cvNamedWindow("reference", CV_WINDOW_AUTOSIZE);
        cvShowImage("reference", img);

        cvWaitKey(0);

        similarity = maxval[0];

        /* free memory*/
        cvReleaseImage(img);
        cvReleaseImage(tpl);
        cvReleaseImage(res);

        return similarity;
    }
when I run it in the main function there is no problem, but when I invok the 
function 
in at servlet or rest service there cause a class not found exception, How can 
I solve the problem.

Original comment by [email protected] on 18 Apr 2014 at 6:44

from javacv.

GoogleCodeExporter avatar GoogleCodeExporter commented on July 28, 2024
hey  [email protected]

I am having the same situation with struts2, with main it runs fine but when 
itegrating with struts2 it gives the exception....hoping someone will give us 
the solution..quickly.

Original comment by [email protected] on 23 Apr 2014 at 10:33

from javacv.

GoogleCodeExporter avatar GoogleCodeExporter commented on July 28, 2024
We usually need to do something special for JNI and containers like Struts. 
Please read their documentation and follow what they say we should do in the 
case of JNI.

Original comment by [email protected] on 7 May 2014 at 1:40

from javacv.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.