Closed GoogleCodeExporter closed 8 years ago
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 samuel.a...@gmail.com
on 4 Nov 2011 at 4:12
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 andrew.c...@gmail.com
on 4 Nov 2011 at 8:49
[deleted comment]
I got it. Thanks anyway.
Original comment by bphan...@gmail.com
on 22 Nov 2011 at 3:31
Mind sharing your solution?
Original comment by andrew.c...@gmail.com
on 22 Nov 2011 at 2:09
Typing the export command above in a Terminal window does not work?
Original comment by samuel.a...@gmail.com
on 26 Nov 2011 at 6:04
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 triggull...@gmail.com
on 29 Nov 2011 at 5:37
export DYLD_FALLBACK_LIBRARY_PATH=/opt/local/lib/
also worked for me.
(OSX)
Original comment by jerda...@speakeasy.net
on 2 Dec 2011 at 6:35
Fixed in latest release!
Original comment by samuel.a...@gmail.com
on 8 Jan 2012 at 3:46
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 josely...@gmail.com
on 18 Apr 2014 at 6:44
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 josely...@gmail.com
on 18 Apr 2014 at 6:44
hey josely...@gmail.com
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 abhijitb...@gmail.com
on 23 Apr 2014 at 10:33
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 samuel.a...@gmail.com
on 7 May 2014 at 1:40
Hey , are there a solution for this issue?
Original comment by topcum...@gmail.com
on 12 Apr 2015 at 3:25
Original issue reported on code.google.com by
andrew.c...@gmail.com
on 3 Nov 2011 at 5:21