How to use FastFeatureDetector or the general FeatureDetector interface?

1,866 views
Skip to first unread message

Jarek Sacha

unread,
Aug 9, 2011, 10:08:48 PM8/9/11
to jav...@googlegroups.com
I am trying to run examples from OpenCV 2 book using javacv. Many of them work quite fine when accessing through “C” API. I got stuck on FastFeatureDetector, looks that it only has “C++” API. However it crashes JVM. I am trying code like this:

import java.io.File;
import static com.googlecode.javacv.cpp.opencv_core.*;
import static com.googlecode.javacv.cpp.opencv_features2d.*;
import static com.googlecode.javacv.cpp.opencv_highgui.*;

public final class Ex2FAST {
    public static void main(String[] args) {
        // Read input image
        final File file = new File("church01.jpg");
        final CvMat image = cvLoadImageM("church01.jpg", 0);
        if (image == null) {
            System.out.println("Couldn't load source image: " + file.getAbsolutePath());
            System.exit(1);
        }

        final FastFeatureDetector ffd = new FastFeatureDetector(40, true);
        final CvArr imageA = new CvArr(image);
        final KeyPoint keyPoints = new KeyPoint();
        ffd.detect(imageA, keyPoints, new CvArr());

        System.out.println("keyPoints: " + keyPoints.capacity());
    }
}

It crashes on line ffd.detect(…) with message:
# A fatal error has been detected by the Java Runtime Environment:
#
#  EXCEPTION_ACCESS_VIOLATION (0xc0000005) at pc=0x66099fc9, pid=7892, tid=7912
#

I am not completely clear if I am setting parameters right (imageA, keyPoints, new CvArr()).

Any thoughts?

Thanks,

Jarek

Samuel Audet

unread,
Aug 11, 2011, 8:34:13 AM8/11/11
to jav...@googlegroups.com
Hello,

"new CvArr()" should work, but please try to use "null" instead, and the
same for "imageA", please try to replace that with "image". Maybe there
is a bug related with this kind of weird usage... Let me know if it
changes anything, thanks

Samuel

On 2011-08-10 11:08, Jarek Sacha wrote:
> I am trying to run examples from OpenCV 2 book using javacv. Many of

> them work quite fine when accessing through �C� API. I got stuck on
> FastFeatureDetector, looks that it only has �C++� API. However it


> crashes JVM. I am trying code like this:
>
> import java.io.File;
>
> import static com.googlecode.javacv.cpp.opencv_core.*;
> import static com.googlecode.javacv.cpp.opencv_features2d.*;
> import static com.googlecode.javacv.cpp.opencv_highgui.*;
>
> public final class Ex2FAST {
> public static void main(String[] args) {
> // Read input image
> final File file = new File("church01.jpg");
> final CvMat image = cvLoadImageM("church01.jpg", 0);
> if (image == null) {
> System.out.println("Couldn't load source image: " +
> file.getAbsolutePath());
> System.exit(1);
> }
>
> final FastFeatureDetector ffd = new FastFeatureDetector(40,
> true);
> final CvArr imageA = new CvArr(image);
> final KeyPoint keyPoints = new KeyPoint();
> ffd.detect(imageA, keyPoints, new CvArr());
>
> System.out.println("keyPoints: " + keyPoints.capacity());
> }
>
> }
>
>

> It crashes on lineffd.detect(�) with message:


>
> # A fatal error has been detected by the Java Runtime Environment:
> #
> # EXCEPTION_ACCESS_VIOLATION (0xc0000005) at pc=0x66099fc9,
> pid=7892, tid=7912
> #

> �

Jarek

unread,
Aug 11, 2011, 8:23:59 PM8/11/11
to jav...@googlegroups.com, Samuel Audet
As you suggested. I changed code to:

final CvMat image = cvLoadImageM(file.getAbsolutePath(), 0);


final FastFeatureDetector ffd = new FastFeatureDetector(40, true);

final KeyPoint keyPoints = new KeyPoint();

ffd.detect(image, keyPoints, null)

JVM still crashes, part of the log:

Stack: [0x00230000,0x00280000], sp=0x0027f45c, free space=317k
Native frames: (J=compiled Java code, j=interpreted, Vv=VM code,
C=native code)
C [opencv_features2d230.dll+0x29fbd]
cv::OpponentColorDescriptorExtractor::OpponentColorDescriptorExtractor+0xa1d
C [opencv_features2d230.dll+0x45232] cv::Mat::MStep::operator unsigned
int+0x22e2
C [opencv_features2d230.dll+0x45413] cv::FAST+0x193
C [opencv_features2d230.dll+0x2eb4d]
cv::FastFeatureDetector::detectImpl+0x8d
C [opencv_features2d230.dll+0x30272] cv::FeatureDetector::detect+0x212
C [jniopencv_features2d3837367272959595118.dll+0x2ce61]
Java_com_googlecode_javacv_cpp_opencv_1features2d_00024FeatureDetector_detect__Lcom_googlecode_javacv_cpp_opencv_1core_00024CvArr_2Lcom_googlecode_javacv_cpp_opencv_1features2d_00024KeyPoint_2Lcom_googlecode_javacv_cpp_opencv_1core_00024CvArr_2+0x1c1

Do you have an example of using FeatureDetector interface?

Samuel Audet

unread,
Aug 13, 2011, 4:19:21 AM8/13/11
to jav...@googlegroups.com
On 2011-08-12 09:23, Jarek wrote:
> As you suggested. I changed code to:
>
> final CvMat image = cvLoadImageM(file.getAbsolutePath(), 0);
> final FastFeatureDetector ffd = new FastFeatureDetector(40, true);
> final KeyPoint keyPoints = new KeyPoint();
> ffd.detect(image, keyPoints, null)
>
> JVM still crashes, part of the log:

Hum, it looks like MSVC 2010 isn't fully compatible with MSVC 2008.. It
seems to work fine with the prebuilt DLLs in the "vc9" directory of
OpenCV 2.3.0, so be sure to try those..

Otherwise, you could try to recompile everything with your favorite
compiler. That will work for sure.

Samuel

Jarek

unread,
Aug 15, 2011, 3:47:03 PM8/15/11
to jav...@googlegroups.com, Samuel Audet
I tried vc9 directory. Still getting crashes though stack is different
(see below). I tried 32 and 64 bit using Java 6 and Java 7, vc9 and vc10
binaries. Crash stack are a bit different but it always crashing.

I assume that you are talking about recompiling javacv. How do I do that
on Windows 7 64-bit with VS2010?
I got javacpp and javacv project sources next to each other. Somehow I
need to let the javacv build know where OpenCV is, I am getting an error
when executing javacv build:
fatal error C1083: Cannot open include file: 'opencv2/core/core.hpp':

Thanks,

Jarek

Stack: [0x00380000,0x003d0000], sp=0x003cf2a8, free space=316k


Native frames: (J=compiled Java code, j=interpreted, Vv=VM code,
C=native code)

C [ntdll.dll+0x33280] RtlImageNtHeader+0x11c
C [ntdll.dll+0x33587] RtlImageNtHeader+0x423
C [ntdll.dll+0x33472] RtlImageNtHeader+0x30e
C [kernel32.dll+0x114dd] HeapFree+0x14
C [MSVCR90.dll+0x63c1b] free+0xcd
C [opencv_features2d230.dll+0x24c58]
cv::SurfDescriptorExtractor::computeImpl+0xd48

Samuel Audet

unread,
Aug 15, 2011, 8:19:43 PM8/15/11
to Jarek, jav...@googlegroups.com

The precompiled binaries of both work fine for me, so unless I can reproduce it, I won't be able to fix it.

To recompile, just set all the paths on the command line as usual, and type “ant“ as usual...

Samuel

2011/08/16 4:47 "Jarek" <jarek...@gmail.com>:

Jarek

unread,
Aug 16, 2011, 11:30:09 PM8/16/11
to Samuel Audet, jav...@googlegroups.com
I have rebuild javacv wrappers (disabling all libraries but opencv, that
is without avcodec and others). JVM is still crashing, with different
stack trace though. Any suggestion how to diagnose it closer?

Stack: [0x00000000023c0000,0x00000000024c0000], sp=0x00000000024be820,
free space=1018k


Native frames: (J=compiled Java code, j=interpreted, Vv=VM code,
C=native code)

C [ntdll.dll+0x53332] RtlFreeHeap+0x132

Java frames: (J=compiled Java code, j=interpreted, Vv=VM code)
j
com.googlecode.javacv.cpp.opencv_features2d$FeatureDetector.detect(Lcom/googlecode/javacv/cpp/opencv_core$CvArr;Lcom/googlecode/javacv/cpp/opencv_features2d$KeyPoint;Lcom/googlecode/javacv/cpp/opencv_core$CvArr;)V+0
j name.laganiere.opencv2book.chapter8.Ex2FAST.main([Ljava/lang/String;)V+80
v ~StubRoutines::call_stub
j
sun.reflect.NativeMethodAccessorImpl.invoke0(Ljava/lang/reflect/Method;Ljava/lang/Object;[Ljava/lang/Object;)Ljava/lang/Object;+0
j
sun.reflect.NativeMethodAccessorImpl.invoke(Ljava/lang/Object;[Ljava/lang/Object;)Ljava/lang/Object;+87
j
sun.reflect.DelegatingMethodAccessorImpl.invoke(Ljava/lang/Object;[Ljava/lang/Object;)Ljava/lang/Object;+6
j
java.lang.reflect.Method.invoke(Ljava/lang/Object;[Ljava/lang/Object;)Ljava/lang/Object;+57
j
com.intellij.rt.execution.application.AppMain.main([Ljava/lang/String;)V+140
v ~StubRoutines::call_stub

On 8/15/2011 8:19 PM, Samuel Audet wrote:
>
> The precompiled binaries of both work fine for me, so unless I can
> reproduce it, I won't be able to fix it.
>
> To recompile, just set all the paths on the command line as usual, and

> type �ant� as usual...
>

Samuel Audet

unread,
Aug 17, 2011, 6:40:52 AM8/17/11
to Jarek, jav...@googlegroups.com

And this with both JavaCV and OpenCV recompiled with the same exact C++ compiler??

2011/08/17 12:30 "Jarek" <jarek...@gmail.com>:
>> type “ant“ as usual...
>>

Jarek

unread,
Aug 17, 2011, 7:50:37 AM8/17/11
to Samuel Audet, jav...@googlegroups.com
Only javacv was recompiled and matching binaries from OpenCV 2.3 distribution used (vc10). I will try to rebuild both.
How to build javacv in debug mode?
>> type �ant� as usual...
>>

Samuel Audet

unread,
Aug 18, 2011, 8:03:36 AM8/18/11
to Jarek, jav...@googlegroups.com
On 2011-08-17 20:50, Jarek wrote:
> Only javacv was recompiled and matching binaries from OpenCV 2.3
> distribution used (vc10). I will try to rebuild both.
> How to build javacv in debug mode?

Hum, never thought about that.. You may modify the compiler options, but
since JavaCPP generates very little code I doubt very much there is a
problem with either that or OpenCV for that matter (have you tried
calling what you need from a program in C++ BTW?). It works just fine in
both Linux and Windows here. You probably just have incompatible
libraries lying around or OpenCV was compiled with MSVC 10.00001 or
something, where Microsoft decided to break compatibility with the exact
thing you need here.. So, this is why I am suggesting to recompile
everything with the same exact compiler, same exact cl.EXE file, with
the same exact libraries, DLLs, etc. in the path and same exact
everything: This is C++ we are talking about here, it's not Java. There
exists no "standard C++" whatever they may say

Samuel

Jarek

unread,
Aug 19, 2011, 4:34:54 PM8/19/11
to Samuel Audet, jav...@googlegroups.com
On 8/18/2011 8:03 AM, Samuel Audet wrote:
> Hum, never thought about that.. You may modify the compiler options,
> but since JavaCPP generates very little code I doubt very much there
> is a problem with either that or OpenCV for that matter (have you
> tried calling what you need from a program in C++ BTW?). It works just
> fine in both Linux and Windows here. You probably just have
> incompatible libraries lying around or OpenCV was compiled with MSVC
> 10.00001 or something, where Microsoft decided to break compatibility
> with the exact thing you need here.. So, this is why I am suggesting
> to recompile everything with the same exact compiler, same exact
> cl.EXE file, with the same exact libraries, DLLs, etc. in the path and
> same exact everything: This is C++ we are talking about here, it's not
> Java. There exists no "standard C++" whatever they may say

I did rebuild OpenCV and JavaCV with the same compiler, still the same
crashes. I have tested C++ using VS2010 and the same OpenCV binaries, no
problems. Note that I can ran parts of JavaCV. For instance, I can run
function track1() below but not track2() - the JVM crashes on
gftt.detect(...). Note that native part of crash stack is very short
(details at the end), only
C [ntdll.dll+0x53332] RtlFreeHeap+0x132
As is JNI part was making wrong calls. Something with convertingKeyPoint
to std::vector<cv::KeyPoint>?Windows 7 issue?

My idea was to "translate" examples from the OpenCV2 book to JVM and
make them available as part of a JavaCV tutorial. I have many things
working, for instance, complete Chapter 4 on morphological operations
and parts of others that I tried. I got stuck on Chapter 8 "Detecting
and Matching Interest Points", with JVM crashes. I really want to make
it work, though not sure what to do next to resolve it.

import static com.googlecode.javacv.cpp.opencv_core.*;
import static com.googlecode.javacv.cpp.opencv_features2d.*;

import static com.googlecode.javacv.cpp.opencv_highgui.cvLoadImage;
import static
com.googlecode.javacv.cpp.opencv_imgproc.cvGoodFeaturesToTrack;

public final class Ch08_ex01_GoodFeaturesToTrack {

private static void track1(final IplImage image) {
final IplImage eigImage = cvCreateImage(cvGetSize(image),
IPL_DEPTH_32F, 1);
final IplImage tempImage = cvCreateImage(cvGetSize(image),
IPL_DEPTH_32F, 1);
final int maxCorners = 500;
final CvPoint2D32f corners = new CvPoint2D32f(maxCorners);
final int[] cornerCount = new int[]{maxCorners};
cvGoodFeaturesToTrack(image, eigImage, tempImage, corners,
cornerCount, 0.01, 10, null, 3, 1, 0.04);

System.out.println("cornerCount: " + cornerCount[0]);
}

private static void track2(final IplImage image) {
final GoodFeaturesToTrackDetector gftt = new
GoodFeaturesToTrackDetector(500, 0.01, 10.0, 3, false, 0.04);


final KeyPoint keyPoints = new KeyPoint();

gftt.detect(image, keyPoints, null);

System.out.println("keyPoints: " + keyPoints.capacity());
}

public static void main(String[] args) {

final IplImage image = cvLoadImage("church01.jpg", 0);
// track1(image);
track2(image);
}
}

Stack: [0x00000000025e0000,0x00000000026e0000], sp=0x00000000026de890,

free space=1018k
Native frames: (J=compiled Java code, j=interpreted, Vv=VM code,
C=native code)
C [ntdll.dll+0x53332] RtlFreeHeap+0x132

Java frames: (J=compiled Java code, j=interpreted, Vv=VM code)
j
com.googlecode.javacv.cpp.opencv_features2d$FeatureDetector.detect(Lcom/googlecode/javacv/cpp/opencv_core$CvArr;Lcom/googlecode/javacv/cpp/opencv_features2d$KeyPoint;Lcom/googlecode/javacv/cpp/opencv_core$CvArr;)V+0
j

name.laganiere.opencv2book.chapter8.Ch08_ex01_GoodFeaturesToTrack.track2(Lcom/googlecode/javacv/cpp/opencv_core$IplImage;)V+34
j
name.laganiere.opencv2book.chapter8.Ch08_ex01_GoodFeaturesToTrack.main([Ljava/lang/String;)V+12

Samuel Audet

unread,
Aug 20, 2011, 6:43:49 AM8/20/11
to Jarek, jav...@googlegroups.com
On 2011-08-20 05:34, Jarek wrote:
> I did rebuild OpenCV and JavaCV with the same compiler, still the same
> crashes. I have tested C++ using VS2010 and the same OpenCV binaries, no

I will be releasing a new version soon for OpenCV 2.3.1 and I am
compiling it with MSVC 10 this time. Your code still works just fine
here with the precompiled binaries, so just wait for it I guess...

> problems. Note that I can ran parts of JavaCV. For instance, I can run
> function track1() below but not track2() - the JVM crashes on

Right, your track1() uses C functions, while the track2() uses C++. Two
different standards entirely. The C standard is good, the C++, not so
much... That's why most people use Java :)

> My idea was to "translate" examples from the OpenCV2 book to JVM and
> make them available as part of a JavaCV tutorial. I have many things

that would be great! Keep up informed of your progress

Samuel

Samuel Audet

unread,
Aug 20, 2011, 9:46:33 PM8/20/11
to Jarek, jav...@googlegroups.com
On 2011-08-20 19:43, Samuel Audet wrote:
> On 2011-08-20 05:34, Jarek wrote:
>> I did rebuild OpenCV and JavaCV with the same compiler, still the same
>> crashes. I have tested C++ using VS2010 and the same OpenCV binaries, no
>
> I will be releasing a new version soon for OpenCV 2.3.1 and I am
> compiling it with MSVC 10 this time. Your code still works just fine
> here with the precompiled binaries, so just wait for it I guess...

I released it a few hours ago. Let me know if you hit any problems with
that version, thanks!

Samuel

Jarek

unread,
Aug 21, 2011, 10:17:11 PM8/21/11
to Samuel Audet, jav...@googlegroups.com
I am still getting the same crashes. Even after I rebuild both OpenCV
2.3.1 and JavaCV 2.3.1. This on Windows 7 64. I also tested earlier
2.3.0 on Vista 32, using downloaded binaries, crashes with a bit
different stack trace. Tested 2.3.0 on Ubuntu 32 and worked fine. What
OS are you using?

By the way. I have created a project
http://code.google.com/p/javacv-examples/ and stated uploading examples
that I verified to work. So far uploaded a couple of Scala examples for
chapter 5 of the OpenCV2 Cookbook (morphological filters). I will make
an official announcement once I write a description how to setup an IDE
to easily run them.

Samuel Audet

unread,
Aug 22, 2011, 7:58:23 AM8/22/11
to Jarek, jav...@googlegroups.com
On 2011-08-22 11:17, Jarek wrote:
>> I released it a few hours ago. Let me know if you hit any problems
>> with that version, thanks!
> I am still getting the same crashes. Even after I rebuild both OpenCV
> 2.3.1 and JavaCV 2.3.1. This on Windows 7 64. I also tested earlier
> 2.3.0 on Vista 32, using downloaded binaries, crashes with a bit

Strange.. let me know if you figure out something

> different stack trace. Tested 2.3.0 on Ubuntu 32 and worked fine. What
> OS are you using?

Windows XP x64

> By the way. I have created a project
> http://code.google.com/p/javacv-examples/ and stated uploading examples
> that I verified to work. So far uploaded a couple of Scala examples for
> chapter 5 of the OpenCV2 Cookbook (morphological filters). I will make
> an official announcement once I write a description how to setup an IDE
> to easily run them.

Great! But wouldn't it make more sense to add the material directly to
JavaCV's project page?

Samuel

Jarek

unread,
Aug 22, 2011, 8:48:19 AM8/22/11
to Samuel Audet, jav...@googlegroups.com
On 8/22/2011 7:58 AM, Samuel Audet wrote:
> different stack trace. Tested 2.3.0 on Ubuntu 32 and worked fine. What
>> OS are you using?
>
> Windows XP x64
Do you know if anybody running this on Windows 7? I may try to create a
JNI wrapper from scratch for a FeatureDetector to diagnose.

>
>> By the way. I have created a project
>> http://code.google.com/p/javacv-examples/ and stated uploading examples
>> that I verified to work. So far uploaded a couple of Scala examples for
>> chapter 5 of the OpenCV2 Cookbook (morphological filters). I will make
>> an official announcement once I write a description how to setup an IDE
>> to easily run them.
>
> Great! But wouldn't it make more sense to add the material directly to
> JavaCV's project page?
Glad to move it into a module within a JavaCV projects. I would keep
OpenCV2 Cookbook examples separate from other code as it is intended to
be a companion to the book. Renamed current OpenCV_Cookbook module to
OpenCV2_Cookbook_Examples, or opencv2_cookbook_examples (suggestions?).
I will need commit access to JavaCV source and wiki.

Samuel Audet

unread,
Aug 26, 2011, 11:41:01 AM8/26/11
to Jarek, jav...@googlegroups.com
On 2011-08-22 21:48, Jarek wrote:
> On 8/22/2011 7:58 AM, Samuel Audet wrote:
>> different stack trace. Tested 2.3.0 on Ubuntu 32 and worked fine. What
>>> OS are you using?
>>
>> Windows XP x64
> Do you know if anybody running this on Windows 7? I may try to create a
> JNI wrapper from scratch for a FeatureDetector to diagnose.

I have just tested it on my crappy 32-bit Vista, and behold, it fails!
The trace always differs yes. Seems like it's trying to dereference
uninitialized memory for some reason. In any case, it looks like a
common problem with no solution:
http://stackoverflow.com/questions/1144034/how-to-diagnose-java-jni-exception-access-violation-errors-in-windows-vista

As one of the answers suggest, we should try to compile OpenCV and
JavaCV using the same compiler as the JRE, i.e.: MS VC++ 7.1 ...

Hum ... good luck with that :) Let me know if you find a solution

> Glad to move it into a module within a JavaCV projects. I would keep
> OpenCV2 Cookbook examples separate from other code as it is intended to
> be a companion to the book. Renamed current OpenCV_Cookbook module to
> OpenCV2_Cookbook_Examples, or opencv2_cookbook_examples (suggestions?).
> I will need commit access to JavaCV source and wiki.

Sure that sounds great! I added you as a contributor. Let me know before
making any "big" changes... thanks

Samuel

Jarek

unread,
Aug 26, 2011, 3:56:58 PM8/26/11
to Samuel Audet, jav...@googlegroups.com
On 8/26/2011 11:41 AM, Samuel Audet wrote:
> I have just tested it on my crappy 32-bit Vista, and behold, it fails!
> The trace always differs yes. Seems like it's trying to dereference
> uninitialized memory for some reason. In any case, it looks like a
> common problem with no solution:
> http://stackoverflow.com/questions/1144034/how-to-diagnose-java-jni-exception-access-violation-errors-in-windows-vista
>
>
> As one of the answers suggest, we should try to compile OpenCV and
> JavaCV using the same compiler as the JRE, i.e.: MS VC++ 7.1 ...
Actually I am using Java 7 that seems to be compiled with VC++10 judging
by msvcr100.dll in 'bin' directory (though running with Java 6 has the
same problem). This msvcr100.dll loaded from Java installation bin
directory is in the crash stack. There is also a
C:\Windows\system32\msvcrt.dll in my crash stack (many of Windows
systems libraries depend on it). I do not see any other msvcr in the
crash stack. So the suggestion in StackOverflow may not hold here. I am
checking if Windows SDK has some tools that me be useful here (the web
installer for the SDK takes its time...).

Jarek

unread,
Aug 26, 2011, 9:55:37 PM8/26/11
to jav...@googlegroups.com, Samuel Audet
Looks that I have a fix to the problem. I created a Visual Studio
solution to build DLLs from *.cpp files generated by JavaCPP, using
default options for debug build. When I use those DLLs there are no
crashes. FutureDetectors work without problems (at least SURF and SIFT
that I tested). Actually all 7 examples that are now in javacv-examples
work (there some issues with Ex4WatershedSegmentation, may be related to
an error in the example code).

This suggests that the compiler options used by JavaCPP on Windows needs
to be adjusted to defaults used by Visual Studio 2010 DLL project.


Samuel Audet

unread,
Aug 27, 2011, 3:18:26 AM8/27/11
to Jarek, jav...@googlegroups.com
On 2011-08-27 10:55, Jarek wrote:
> Looks that I have a fix to the problem. I created a Visual Studio
> solution to build DLLs from *.cpp files generated by JavaCPP, using
> default options for debug build. When I use those DLLs there are no
> crashes. FutureDetectors work without problems (at least SURF and SIFT
> that I tested). Actually all 7 examples that are now in javacv-examples
> work (there some issues with Ex4WatershedSegmentation, may be related to
> an error in the example code).
>
> This suggests that the compiler options used by JavaCPP on Windows needs
> to be adjusted to defaults used by Visual Studio 2010 DLL project.

So it works with the Debug build options, but not the Release ones?

thanks for looking into this!

Samuel

Jarek

unread,
Aug 27, 2011, 9:15:43 AM8/27/11
to jav...@googlegroups.com, Samuel Audet
I did not try Release build yet.

Jarek

unread,
Aug 27, 2011, 9:46:36 PM8/27/11
to jav...@googlegroups.com, Samuel Audet
No crashes in with a release build neither.
All 7 examples work fine except Ex4WatershedSegmentation
http://code.google.com/p/javacv-examples/source/browse/trunk/OpenCV2_Cookbook/src/main/scala/opencv2_cookbook/chapter05/Ex4WatershedSegmentation.scala
There is some suspicious thing with cvConvertScale or cvCreateImage
after line 48, images are corrupted and corruption patters changes from
run to run. If i remember the same problem was on Linux too. May need to
write some stress test to see if the corruption shows up after repeated
calls to cvConvertScale or cvCreateImage or it may be in
WatershedSegmenter.process()

Samuel Audet

unread,
Aug 27, 2011, 10:03:09 PM8/27/11
to Jarek, jav...@googlegroups.com
On 2011-08-28 10:46, Jarek wrote:
> No crashes in with a release build neither.

Hum, thanks for testing. I do not have Visual Studio 2010 myself, just
using the Windows SDK, so I do not know what options it may be using..
Knowing Microsoft, they probably try to hide it, but if you figure it
out, let me know, thanks

> All 7 examples work fine except Ex4WatershedSegmentation
> http://code.google.com/p/javacv-examples/source/browse/trunk/OpenCV2_Cookbook/src/main/scala/opencv2_cookbook/chapter05/Ex4WatershedSegmentation.scala
>
> There is some suspicious thing with cvConvertScale or cvCreateImage
> after line 48, images are corrupted and corruption patters changes from
> run to run. If i remember the same problem was on Linux too. May need to
> write some stress test to see if the corruption shows up after repeated
> calls to cvConvertScale or cvCreateImage or it may be in
> WatershedSegmenter.process()

It's probably in C++ functions, I'm pretty sure all C functions work
just fine.

Thank you very much for all the work on this!!

Samuel

Jarek

unread,
Aug 28, 2011, 12:24:47 AM8/28/11
to Samuel Audet, jav...@googlegroups.com
On 8/27/2011 10:03 PM, Samuel Audet wrote:
> On 2011-08-28 10:46, Jarek wrote:
>
>> All 7 examples work fine except Ex4WatershedSegmentation
>> http://code.google.com/p/javacv-examples/source/browse/trunk/OpenCV2_Cookbook/src/main/scala/opencv2_cookbook/chapter05/Ex4WatershedSegmentation.scala
>>
>
Actually the problem with WatershedSegmenter was a bug in my code
(somehow I used 'def' instead of 'val', so variables were not
initialized as intended). I committed a fix.
Last thing remaining is to figure out VC++ options used by VC2010. I
will get to it next week. Then I can get back to completing the Cookbook
examples:)
Reply all
Reply to author
Forward
0 new messages