sheena19 / javacv Goto Github PK
View Code? Open in Web Editor NEWAutomatically exported from code.google.com/p/javacv
License: GNU General Public License v2.0
Automatically exported from code.google.com/p/javacv
License: GNU General Public License v2.0
=JavaCV= ==Introduction== JavaCV first provides wrappers to commonly used libraries by researchers in the field of computer vision: [http://opencv.org/ OpenCV], [http://ffmpeg.org/ FFmpeg], [http://damien.douxchamps.net/ieee1394/libdc1394/ libdc1394], [http://www.ptgrey.com/products/pgrflycapture/ PGR FlyCapture], [http://openkinect.org/ OpenKinect], [http://muonics.net/school/spring05/videoInput/ videoInput], and [http://studierstube.icg.tugraz.at/handheld_ar/artoolkitplus.php ARToolKitPlus]. The classes found under the `com.googlecode.javacv.cpp` package namespace expose their complete APIs. Moreover, utility classes make their functionality easier to use on the Java platform, including Android. JavaCV also comes with hardware accelerated full-screen image display (`CanvasFrame` and `GLCanvasFrame`), easy-to-use methods to execute code in parallel on multiple cores (`Parallel`), user-friendly geometric and color calibration of cameras and projectors (`GeometricCalibrator`, `ProCamGeometricCalibrator`, `ProCamColorCalibrator`), detection and matching of feature points (`ObjectFinder`), a set of classes that implement direct image alignment of projector-camera systems (mainly `GNImageAligner`, `ProjectiveTransformer`, `ProjectiveColorTransformer`, `ProCamTransformer`, and `ReflectanceInitializer`), a blob analysis package (`Blobs`), as well as miscellaneous functionality in the `JavaCV` class. Some of these classes also have an OpenCL and OpenGL counterpart, their names ending with `CL` or starting with `GL`, i.e.: `JavaCVCL`, `GLCanvasFrame`, etc. To learn how to use the API, since documentation currently lacks, please refer to the [#Quick_Start_for_OpenCV_and_FFmpeg] section below as well as the [http://code.google.com/p/javacv/source/browse/samples/ sample programs], including two for Android (`FacePreview.java` and `RecordActivity.java`), also found in the `samples` directory. You may also find it useful to refer to the source code of [http://code.google.com/p/javacv/source/browse?repo=procamcalib ProCamCalib] and [http://code.google.com/p/javacv/source/browse?repo=procamtracker ProCamTracker] as well as [http://code.google.com/p/javacv/source/browse?repo=examples Examples ported from OpenCV2 Cookbook] and the associated [http://code.google.com/p/javacv/wiki/OpenCV2_Cookbook_Examples Wiki pages]. Please keep me informed of any updates or fixes you make to the code so that I may integrate them into the next release. Thank you! And feel free to ask questions on [http://groups.google.com/group/javacv the mailing list] if you encounter any problems with the software! I am sure it is far from perfect... ==Required Software== To use JavaCV, you will need to download and install the following software: * An implementation of Java SE 6 or 7 * OpenJDK http://openjdk.java.net/install/ or * Sun JDK http://www.oracle.com/technetwork/java/javase/downloads/ or * IBM JDK http://www.ibm.com/developerworks/java/jdk/ or * Java SE for Mac OS X http://developer.apple.com/java/ etc. * OpenCV 2.4.8 http://sourceforge.net/projects/opencvlibrary/files/ * Precompiled and prepackaged CPPJARs for Linux, Mac OS X, Windows, and Android: * http://code.google.com/p/javacv/downloads/list And please make sure your Java and OpenCV have the same bitness: *32-bit and 64-bit modules do not mix under any circumstances*. Further, although not always required, some functionality of JavaCV also relies on: * FFmpeg 2.1.x http://ffmpeg.org/download.html * Precompiled and prepackaged CPPJARs for Linux, Mac OS X, Windows, and Android: * http://code.google.com/p/javacv/downloads/list * libdc1394 2.1.x or 2.2.x http://sourceforge.net/projects/libdc1394/files/ * PGR FlyCapture 1.7 or newer (Windows only) http://www.ptgrey.com/products/pgrflycapture/ * OpenKinect http://openkinect.org/ * CL Eye Platform SDK (Windows only) http://codelaboratories.com/downloads/ * Android SDK API 8 or newer http://developer.android.com/sdk/ * JOCL and JOGL from JogAmp http://jogamp.org/ * ARToolKitPlus 2.3.0 https://launchpad.net/artoolkitplus Finally, because we are dealing with native code, bugs can easily crash the virtual machine. Luckily, Java provides some tools to help us debug under those circumstances: * Troubleshooting Guide for Java SE with HotSpot VM * http://www.oracle.com/technetwork/java/javase/index-137495.html * http://www.oracle.com/technetwork/java/javase/tsg-vm-149989.pdf * http://docs.oracle.com/javase/7/docs/webnotes/tsg/TSG-VM/html/ ==Build Instructions== To rebuild the source code, please note that the project files were created for: * Maven 2 or 3 http://maven.apache.org/download.html * JavaCPP 0.7 http://code.google.com/p/javacpp/ Once installed, simply call the usual `mvn install` command for both JavaCPP and JavaCV. By default, all the dependencies listed above are NOT required, except for OpenCV and a C++ compiler for JavaCPP, whose command line options can be passed via the `javacpp.options` Maven property, such as [http://code.google.com/p/javacpp/#Instructions_for_Android those required for Android]. Please refer to the comments inside the `pom.xml` file for further details. ==Quick Start for OpenCV and FFmpeg== Simply put all the JAR files of JavaCV (`javacpp.jar`, `javacv.jar`, and `javacv-*.jar`), of OpenCV (`opencv-*.jar`), and of FFmpeg (`ffmpeg-*.jar`) somewhere in your CLASSPATH. Here are some more specific instructions for common cases: NetBeans (Java SE 6 or 7): # In the Projects window, right-click the Libraries node of your project, and select "Add JAR/Folder...". # Locate the JAR files, select them, and click OK. Eclipse (Java SE 6 or 7): # Navigate to Project > Properties > Java Build Path > Libraries and click "Add External JARs...". # Locate the JAR files, select them, and click OK. Eclipse (Android 2.2 or newer): # Follow the instructions on this page: http://developer.android.com/training/basics/firstapp/ # Go to File > New > Folder, select your project as parent folder, type "libs/armeabi" as Folder name, and click Finish. # Copy `javacpp.jar` and `javacv.jar` into the newly created "libs" folder. # Extract all the `*.so` files from `javacv-android-arm.jar`, `opencv-2.4.8-android-arm.jar`, and `ffmpeg-2.1.1-android-arm.jar` directly into the newly created "libs/armeabi" folder, without creating any of the subdirectories found in the JAR files. # Navigate to Project > Properties > Java Build Path > Libraries and click "Add JARs...". # Select both `javacpp.jar` and `javacv.jar` from the newly created "libs" folder. Or point your build file to the Maven repository http://maven2.javacv.googlecode.com/git/, and make sure that the library files of OpenCV and FFmpeg (`*.so`, `*.dylib`, or `*.dll`) can be found either in their default installation directories or in the system library PATH, which under Windows includes the current working directory. (For answers to problems frequently encountered with OpenCV on the Windows platform, please refer to [http://code.google.com/p/javacv/wiki/Windows7AndOpenCV Common issues with OpenCV under Windows 7].) After that, the wrapper classes for OpenCV and FFmpeg can automatically access all of their C/C++ APIs: * [http://docs.opencv.org/ OpenCV documentation] * [http://ffmpeg.org/doxygen/ FFmpeg documentation] The class definitions are basically ports to Java of the original header files in C, plus the missing functionality exposed only by the C++ API of OpenCV, and I deliberately decided to keep as much of the original syntax as possible. For example, here is a method that tries to load an image file, smooth it, and save it back to disk: {{{ import static com.googlecode.javacv.cpp.opencv_core.*; import static com.googlecode.javacv.cpp.opencv_imgproc.*; import static com.googlecode.javacv.cpp.opencv_highgui.*; public class Smoother { public static void smooth(String filename) { IplImage image = cvLoadImage(filename); if (image != null) { cvSmooth(image, image, CV_GAUSSIAN, 3); cvSaveImage(filename, image); cvReleaseImage(image); } } } }}} JavaCV also comes with helper classes and methods on top of OpenCV and FFmpeg to facilitate their integration to the Java platform. Here is a small demo program demonstrating the most frequently useful parts: {{{ import java.io.File; import java.net.URL; import com.googlecode.javacpp.Loader; import com.googlecode.javacv.*; import com.googlecode.javacv.cpp.*; import static com.googlecode.javacv.cpp.opencv_core.*; import static com.googlecode.javacv.cpp.opencv_imgproc.*; import static com.googlecode.javacv.cpp.opencv_calib3d.*; import static com.googlecode.javacv.cpp.opencv_objdetect.*; public class Demo { public static void main(String[] args) throws Exception { String classifierName = null; if (args.length > 0) { classifierName = args[0]; } else { URL url = new URL("https://raw.github.com/Itseez/opencv/2.4/data/haarcascades/haarcascade_frontalface_alt.xml"); File file = Loader.extractResource(url, null, "classifier", ".xml"); file.deleteOnExit(); classifierName = file.getAbsolutePath(); } // Preload the opencv_objdetect module to work around a known bug. Loader.load(opencv_objdetect.class); // We can "cast" Pointer objects by instantiating a new object of the desired class. CvHaarClassifierCascade classifier = new CvHaarClassifierCascade(cvLoad(classifierName)); if (classifier.isNull()) { System.err.println("Error loading classifier file \"" + classifierName + "\"."); System.exit(1); } // The available FrameGrabber classes include OpenCVFrameGrabber (opencv_highgui), // DC1394FrameGrabber, FlyCaptureFrameGrabber, OpenKinectFrameGrabber, // PS3EyeFrameGrabber, VideoInputFrameGrabber, and FFmpegFrameGrabber. FrameGrabber grabber = FrameGrabber.createDefault(0); grabber.start(); // FAQ about IplImage: // - For custom raw processing of data, getByteBuffer() returns an NIO direct // buffer wrapped around the memory pointed by imageData, and under Android we can // also use that Buffer with Bitmap.copyPixelsFromBuffer() and copyPixelsToBuffer(). // - To get a BufferedImage from an IplImage, we may call getBufferedImage(). // - The createFrom() factory method can construct an IplImage from a BufferedImage. // - There are also a few copy*() methods for BufferedImage<->IplImage data transfers. IplImage grabbedImage = grabber.grab(); int width = grabbedImage.width(); int height = grabbedImage.height(); IplImage grayImage = IplImage.create(width, height, IPL_DEPTH_8U, 1); IplImage rotatedImage = grabbedImage.clone(); // Objects allocated with a create*() or clone() factory method are automatically released // by the garbage collector, but may still be explicitly released by calling release(). // You shall NOT call cvReleaseImage(), cvReleaseMemStorage(), etc. on objects allocated this way. CvMemStorage storage = CvMemStorage.create(); // The OpenCVFrameRecorder class simply uses the CvVideoWriter of opencv_highgui, // but FFmpegFrameRecorder also exists as a more versatile alternative. FrameRecorder recorder = FrameRecorder.createDefault("output.avi", width, height); recorder.start(); // CanvasFrame is a JFrame containing a Canvas component, which is hardware accelerated. // It can also switch into full-screen mode when called with a screenNumber. // We should also specify the relative monitor/camera response for proper gamma correction. CanvasFrame frame = new CanvasFrame("Some Title", CanvasFrame.getDefaultGamma()/grabber.getGamma()); // Let's create some random 3D rotation... CvMat randomR = CvMat.create(3, 3), randomAxis = CvMat.create(3, 1); // We can easily and efficiently access the elements of CvMat objects // with the set of get() and put() methods. randomAxis.put((Math.random()-0.5)/4, (Math.random()-0.5)/4, (Math.random()-0.5)/4); cvRodrigues2(randomAxis, randomR, null); double f = (width + height)/2.0; randomR.put(0, 2, randomR.get(0, 2)*f); randomR.put(1, 2, randomR.get(1, 2)*f); randomR.put(2, 0, randomR.get(2, 0)/f); randomR.put(2, 1, randomR.get(2, 1)/f); System.out.println(randomR); // We can allocate native arrays using constructors taking an integer as argument. CvPoint hatPoints = new CvPoint(3); while (frame.isVisible() && (grabbedImage = grabber.grab()) != null) { cvClearMemStorage(storage); // Let's try to detect some faces! but we need a grayscale image... cvCvtColor(grabbedImage, grayImage, CV_BGR2GRAY); CvSeq faces = cvHaarDetectObjects(grayImage, classifier, storage, 1.1, 3, CV_HAAR_DO_CANNY_PRUNING); int total = faces.total(); for (int i = 0; i < total; i++) { CvRect r = new CvRect(cvGetSeqElem(faces, i)); int x = r.x(), y = r.y(), w = r.width(), h = r.height(); cvRectangle(grabbedImage, cvPoint(x, y), cvPoint(x+w, y+h), CvScalar.RED, 1, CV_AA, 0); // To access or pass as argument the elements of a native array, call position() before. hatPoints.position(0).x(x-w/10) .y(y-h/10); hatPoints.position(1).x(x+w*11/10).y(y-h/10); hatPoints.position(2).x(x+w/2) .y(y-h/2); cvFillConvexPoly(grabbedImage, hatPoints.position(0), 3, CvScalar.GREEN, CV_AA, 0); } // Let's find some contours! but first some thresholding... cvThreshold(grayImage, grayImage, 64, 255, CV_THRESH_BINARY); // To check if an output argument is null we may call either isNull() or equals(null). CvSeq contour = new CvSeq(null); cvFindContours(grayImage, storage, contour, Loader.sizeof(CvContour.class), CV_RETR_LIST, CV_CHAIN_APPROX_SIMPLE); while (contour != null && !contour.isNull()) { if (contour.elem_size() > 0) { CvSeq points = cvApproxPoly(contour, Loader.sizeof(CvContour.class), storage, CV_POLY_APPROX_DP, cvContourPerimeter(contour)*0.02, 0); cvDrawContours(grabbedImage, points, CvScalar.BLUE, CvScalar.BLUE, -1, 1, CV_AA); } contour = contour.h_next(); } cvWarpPerspective(grabbedImage, rotatedImage, randomR); frame.showImage(rotatedImage); recorder.record(rotatedImage); } frame.dispose(); recorder.stop(); grabber.stop(); } } }}} ==Acknowledgments== This project was conceived at the Okutomi & Tanaka Laboratory, Tokyo Institute of Technology, where I was supported for my doctoral research program by a generous scholarship from the Ministry of Education, Culture, Sports, Science and Technology (MEXT) of the Japanese Government. I extend my gratitude further to all who have reported bugs, donated code, or made suggestions for improvements! ==Changes== * Fixed `FFmpegFrameRecorder` not refreshing the resampler when the format of samples changes (issue #465) * Fixed `ObjectFinder` not working with recent versions of OpenCV, especially on Android (issue #214) * Added new `FrameRecorder.gopSize` property to let users set a desired GOP size instead of the default one of 12 * `FFmpegFrameGrabber` now takes into account calls to `setPixelFormat()` (issue #429), but does not enforce it * Added a `Frame.audioChannels` field for resampling purposes in `FFmpegFrameRecorder` (issue #388) * In `FFmpegFrameRecorder`, fixed audio encoding with the Vorbis codec (issue #428) and the WebM container (issue #435), and other audio related things * Added missing `allocateArray()` constructors to `CameraParams` and `MatchesInfo` (issue #421) * Fixed errors such as "jniopencv_nonfree.dll: Can't find dependent libraries" by adding the `opencv_ocl` module as dependency * Added support to seek in audio-only streams with `FFmpegFrameGrabber.setTimestamp()` (issue #417) * Fixed potential thread concurrency issues and crash in the `stopRecording()` and `onDestroy()` methods of the `RecordActivity` sample, thanks to Jacob Duron * To capture the last frame of a video file, reverted `FFmpegFrameGrabber.setTimestamp()` to its previous behavior (issue #413) * Updated `samples/FaceApplet.jnlp` to make it work with JDK/JRE 7u45 ===January 6, 2014 version 0.7=== * Upgraded support to OpenCV 2.4.8 * Upgraded supported FFmpeg API to the 2.1 release branch * Updated `freenect` to reflect the latest changes of OpenKinect's master branch * Updated `videoInput` to reflect the latest changes in the "update2013" branch * Added `Frame.opaque` field to give access to the raw `AVFrame` in the case of `FFmpegFrameGrabber` (issue #399) * Added new `FFmpegFrameGrabber.grabKeyFrame()` method to grab key frames (I-frames) directly (issue #312) * `VideoInputFrameGrabber` now uses 640x480 as default image size to prevent "videoInput.getPixels() Error: Could not get pixels." * Fixed `FFmpegFrameGrabber.setTimestamp()` not working for streams with audio (issue #398) * Fixed wrong `haarcascade_frontalface_alt.xml` file getting downloaded by the `Demo` class (issue #402) * Added a `Frame.sampleRate` field to allow audio samples to be resampled by `FFmpegFrameRecorder` (issue #388) * Incorporated `IPCameraFrameGrabber` from Greg Perry (issue #384) * Fixed thread safety issues with FFmpeg in `FFmpegFrameGrabber` and `FFmpegFrameRecorder` (issue #377) * Fixed memory leak in the `MotionDetector.java` sample file (issue #372) * New `videoCodecName` and `audioCodecName` properties to allow users of `FFmpegFrameRecorder` to use codecs such as "libx264rgb" (issue #369) ===September 15, 2013 version 0.6=== * Upgraded supported FFmpeg API to the 2.0 release branch (with Java interface files now based on code automatically produced by [https://code.google.com/p/javacpp/wiki/Presets JavaCPP Presets]) * Fixed `FFmpegFrameGrabber.getFrameNumber()` * Upgraded support to OpenCV 2.4.6 * Fixed callbacks when used with custom class loaders such as with Web containers * Upgraded to ARToolKitPlus 2.3.0 (issue #234) * Fixed drawing issues with `MarkerDetector.draw()` * Fixed `FFmpegFrameGrabber.getTimestamp()` not returning values for audio frames (issue #328) * Added new `Frame.keyFrame` field returned by `FFmpegFrameGrabber.grabFrame()` to know when a grabbed frame is a key frame or not (issue #312) * Worked around problem in `samples/RecordActivity.java` that would happen when trying to record a frame with an invalid timestamp (issue #313) * Fixed potential resource leak that could occur after `FFmpegFrameRecorder` throwing an `Exception` * Fixed `FFmpegFrameGrabber` not returning the last few frames of video streams (issue #315) * Fixed wrong dependencies of OpenCV preventing correct loading (issue #304) * Renamed `FrameRecorder.record(Buffer[] samples)` to a cleaner `record(Buffer ... samples)` (issue #303) * Fixed `FFmpegFrameRecorder` not flushing buffers on `stop()` (issue #302) ===April 7, 2013 version 0.5=== * Upgraded support to OpenCV 2.4.5 * Upgraded supported FFmpeg API to the 1.2 release branch * New methods `FFmpegFrameRecorder.setVideoOption()` and `setAudioOption()` generalize the way to set arbitrary codec options, such as "profile", "preset", "tune", etc. used by the x264 codec * Included better format guessing inside `FFmpegFrameRecorder` for protocols like RTP * Added support for planar audio formats to `FFmpegFrameGrabber` and `FFmpegFrameRecorder`, as required by newer versions of FFmpeg for at least MP3 and AAC * Enhanced `FFmpegFrameRecorder` by making it use the closest supported frame rate for the given codec instead of failing * To support variable bitrate (VBR) encoding, appended new `videoQuality` and `audioQuality` properties to `FFmpegFrameRecorder`, which usually have an effective range of [0, 51] and overrides the `videoBitrate` and `audioBitrate` properties ===March 3, 2013 version 0.4=== * Upgraded support to OpenCV 2.4.4 * `CanvasFrame.waitKey(-1)` does not wait anymore and returns the last `KeyEvent` dispatched since the last call to it * Upgraded supported FFmpeg API to the 1.1 release branch * Fixed bug in `FaceRecognition.java` sample (issue #276) * Included `Sobel()`, `Scharr()`, `Laplacian()`, and `Canny()` from `opencv_imgproc` whose equivalent functions in the C API have missing parameters * Extended `OpenKinectFrameGrabber` with `setDepthFormat()` and `setVideoFormat()` methods to be able to set both formats independently (issue #273) * Fixed `Blender.blend()` having its `@OutputMat` incorrectly annotated as `@InputMat` (issue #272) * Added new `RecordActivity.java` Android sample from Shawn Van Every and Qianliang Zhang * Added missing `allocate()` methods for `FunctionPointer` in `AVIOContext` and others, which prevented these FFmpeg callbacks from functioning * Fixed infinite loop in `FrameGrabber.Array.grab()` (as used by ProCamCalib in the case of stereo cameras, issue #262) when `FrameGrabber.getTimestamp()` returns an invalid negative value (as with `opencv_highgui`) or when using different types of (unsynchronized) `FrameGrabber` together * Fixed `cvQueryHistValue_1D()` and other functions that use a raw `CvArr` object * Fixed problem when subclassing `CanvasFrame` ===November 4, 2012 version 0.3=== * Upgraded support to OpenCV 2.4.3 (issue #233) * Fixed functions like `Algorithm.getMat()` and `HOGDescriptor.getDefaultPeopleDetector()` returning `null` instead of the expected data * Implemented better, more transparent, handling of `cv::Ptr` * When allocating an empty `IplImage`, `CvMat`, `CvBGCodeBookModel`, etc. its memory content now gets zeroed out, giving OpenCV a better chance of displaying an error message instead of crashing * Upgraded supported FFmpeg API to the 1.0 release branch * Appended to `StringVector` and `MatVector` new convenient bulk constructors and `put()` methods taking arrays of `String`, `IplImage`, `CvMat`, etc. * Included new `Blobs` module from David Grossman and the corresponding `BlobDemo` sample * Added missing `opencv_core.partition()` function (issue #144) * Fixed up the samples a bit (issue #229 and issue #230) * Switched the majority of `@Adapter` annotations to more concise ones like `@StdVector` as allowed by new capabilities of JavaCPP * Fixed `FFmpegFrameGrabber.getLengthInFrames()` and `OpenCVFrameGrabber.getLengthInTime()` (issue #231 and issue #236) * Enhanced `FFmpegFrameRecorder` to support conversion between audio sample formats (for the experimental AAC encoder among other things) and to let two different threads call `record(samples)` and `record(image)` simultaneously, plus a couple of other features like `setFrameNumber()`, which lets users skip image frames (achieving variable frame rate) * Added a `javacpp.skip` property to `pom.xml`, such that a command like `mvn package -Pall -Djavacpp.skip=true` only recompiles the Java source files, but also added `platform.root` and `compiler.path` properties, which map directly to JavaCPP's for convenience ===July 21, 2012 version 0.2=== * Provided new `javacv-linux-arm.jar` build thanks to Jeremy Nicola (issue #184) * Additional default properties inside `pom.xml` make it easier to build JavaCV from source (issue #202), calling `mvn package` now succeeds with only OpenCV and a C++ compiler for JavaCPP * Made a few minor updates for OpenCV 2.4.2 * New `Pointer.limit` property of JavaCPP can now be used to get the `size` of an output parameter, and to specify the maximum `size` on input as well * Upgraded supported FFmpeg API to the 0.11 release branch * Added audio support to `FFmpegFrameGrabber` (call `grabFrame()` instead of `grab()`) and `FFmpegFrameRecorder` (call `setAudioChannels()` before `start()`, and `record(Frame)` instead of `record(IplImage)`) (issue #160) * Gave better default `FFmpegFrameRecorder` settings to H.263, MPEG-4, etc. codecs and fixed H.264 encoding with libx264 (issue #160) * Refined the `FaceApplet` sample * Fixed `FlannBasedMatcher` constructor, `FaceRecognizer.train()`, and `Stitcher.stitch()/composePanorama()` (issue #211) * Fixed `CanvasFrame` sometimes blanking out under Windows and maybe Linux (issue #212) ===May 27, 2012 version 0.1=== * Started using version numbers, friendly to tools like Maven, and placing packages in a sort of [http://maven2.javacv.googlecode.com/git/ Maven repository] * JavaCV can now extract and load native dependent libraries such as `libopencv_core.so.2.4`, `libopencv_core.2.4.dylib`, `opencv_core240.dll`, etc. from Java resources placed inside the `com.googlecode.javacv.cpp.<platform.name>` package (i.e.: under the `/com/googlecode/javacv/cpp/<platform.name>/` directory of a JAR file in the classpath) (issue #146) * Included new `FaceApplet` sample to demonstrate [http://code.google.com/p/javacv/wiki/HowToMakeAnApplet How to use JavaCV in an applet] * Added handy `IplImage.asCvMat()` and `CvMat.asIplImage()` conversion methods * Fixed a few small things with `OpenCVFrameGrabber`, `opencv_contrib`, `opencv_legacy`, and `opencv_stitching` ===May 12, 2012=== * Upgraded support to OpenCV 2.4.0 (issue #187) * Moved the source code repository to Git * Added `pom.xml` file for Maven support and changed the directory structure of the source code to match Maven's standard directory layout * Made it easier to create one massive statically linked native library by passing something like "-Xcompiler -Wl,-static -o javacv" as command line options to JavaCPP, usually from inside `build.xml` or `pom.xml` (issue #146) * Fixed missing parameter from `CvANN_MLP.create()` * Added methods `cvCalcCovarMatrixEx()`, `cvEigenDecomposite()`, and `cvEigenProjection()` taking an `IplImage[]` as argument for convenience * `VideoInputFrameGrabber.start()` now accepts a `connection` argument such as `VI_COMPOSITE` to support analog cameras and what not * Fixed `FaceRecognition` sample (issue #188) * Added a few convenience methods to avoid the need to create empty `CvAttrList` ===March 29, 2012=== * Added missing array allocators and `position()` methods to `KDTree.Node`, `DefaultRngAuto`, `CvAffinePose`, `KeyPoint`, `BaseKeypoint`, `ReferenceTrees`, `DMatch`, `*.Params`, `CvFuzzy*`, `Octree.Node`, `CvDefParam`, `Cv*Blob*`, `Cv*Track*`, `CvDrawShape`, `CvVectors`, `CvParamGrid`, `Cv*Params`, `CvSVM*`, `CvPair16u32s`, `CvDTree*` `CvTrainTestSplit`, `CvMLData`, `FeatureEvaluator`, and `*DataMatrixCode` * Increased versatility of `IplImage.createFrom()`, `copyFrom()`, `copyTo()`, `getBufferedImage()` by providing a `flipChannels` parameter, whose effect was previously mistakenly forced onto four-channel images of byte values only (issue #163) * Fixed a couple of things with `CvMat.get()/put()` (issue #167) * In addition to an `IplImage`, we may now specify the pixel format of the data when calling `FFmpegFrameRecorder.record()`, but otherwise when `IplImage.nChannels == 2`, it assumes `PIX_FMT_NV21`, allowing for easy and efficient encoding of data captured from the camera on Android (issue #160), image objects we can also convert to RGB using `cvCvtColor()` with `CV_YUV420sp2BGR` * Fixed seeking capabilities of `FFmpegFrameGrabber` (issue #162) and added `getLengthInFrames()` and `getLengthInTime()` methods to query the duration of streams, when known * Enhanced `IplImage.clone()` and `create*Compatible()` with cloning of their `BufferedImage` to make it easier to keep color components in the right order (issue #163) * Refactored `FrameGrabber` and `FrameRecorder` a bit to accommodate new `createDefault(...)` and `create(String className, ...)` factory methods, offering to users an easier selection method to work around limitations of some APIs (issue #70) * Adjusted `GNImageAligner`, `ProCamTransformer`, etc. to support alignment of only the projector display on textureless surface planes * Renamed a few more `Settings` properties to reflect better their meanings ===February 18, 2012=== * Added `GLCanvasFrame` to show OpenGL renderbuffers on screen, plus a new factory method `JavaCVCL.createCLGLImageFrom()` to create compatible ones from `IplImage` objects, as well as more user-friendly `getGLContext()`, `getGL()` and `getGL2()` methods * Fixed various things of the original `CanvasFrame`, and `JavaCV.createCLImage()` and `createIplImage()`, also appending `From` to their names * New `createPinnedBuffer()` and `createPinnedIplImage()` factory methods in `JavaCVCL` to allocate page-locked memory for faster CPU<->GPU transfers, but it does not seem to work for OpenCL image objects, only linear buffer objects :( * Fixed and enhanced `GNImageAlignerCL` and `ProjectorDevice` (its `useOpenGL` property) to support fully OpenCL and OpenGL acceleration * Refactored `Parallel` a bit so that we may set the number of threads it uses via its static `numThreads` property or the "com.googlecode.javacv.numthreads" system property, which defaults to `Parallel.getNumCores() = Runtime.getRuntime().availableProcessors()` * Cleaned up and renamed some methods in `JavaCV`, while adding `boundingRect()`, functionally similar to `cvBoundingRect`, but better adapted to compute a properly aligned and padded ROI * Inserted a couple of missing `allocate()` inside `opencv_flann` * Updated `ObjectFinder` with a `Settings.useFLANN` property to let it use FLANN via OpenCV * Cleaned up and optimized `HandMouse` * `CanvasFrame`, `FrameGrabber`, `FrameRecorder`, and `ProjectiveDevice` objects now throw `Exception` objects of a nested class instead of the too generic `java.lang.Exception` one * Moved parallel execution of `cvkernels.multiWarpColorTransform()`, modifying `ImageTransformer` classes, from `GNImageAligner` into `cvkernels`, which now also supports other image types than `float` * Renamed some `Settings` properties here and there to correct typos and reflect better their meanings * Updated `freenect` to reflect the latest changes of OpenKinect's master branch * FFmpeg and other libraries did not work under Android when compiled with the latest NDK, r7 (issue #147): Fixed in JavaCPP * Moved `IplImage.timestamp` to `FrameGrabber`, also adding a `frameNumber` property, both allowing to seek within streams too * Removed `triggerFlushSize` property from `CameraDevice` and `FrameGrabber`, instead relying on the `numBuffers` property to decide the required size of a buffer flush * Corrected the logic behind `FFmpegFrameGrabber.getFrameRate()` and `getTimestamp()` (issue #151) * Created a `BufferRing` class for convenient circular rings of large buffers that require manual release of resources, such as OpenCL memory * Added a few more useful methods to `FrameGrabber`, including `restart()`, `flush()`, and `delayedGrab()` (to be used in conjunction with `getDelayedTime()` and `getDelayedImage()`) * Inserted `cvLoadImageBGRA()` and `cvLoadImageRGBA()` methods into `opencv_highgui` to load color images compatible with OpenCL more easily * `JavaCvErrorCallback` now outputs messages to `Logger` instead of `System.err` * Defined `VI_COM_MULTI_THREADED` for `videoInput`, allowing it to run on multiple threads if needed ===January 8, 2012=== * JavaCV should now have an easier time automatically finding libraries inside standard directories such as `/usr/local/lib/`, `/opt/local/lib/`, and `C:\opencv\`, even when they are not part of the system configuration or PATH (issue #127) * Renamed `set()` and `fill()` methods to `put()` inside `CvPoint*` classes, for better naming consistency * Renamed `FrameGrabber.ColorMode` to `ImageMode` and its `BGR` value to `COLOR` to reflect the fact that a `FrameGrabber` instance can return color images in some arbitrary format, but added a new `pixelFormat` property to let users know or specify the exact pixel format desired, such as `PIX_FMT_BGR24`, etc. in the case of `FFmpegFrameGrabber` * After `FFmpegFrameGrabber.start()`, the `format`, `imageWidth`, `imageHeight`, and `frameRate` properties switch to their effective values * Added new `FrameGrabber.sensorPattern` property to obtain the Bayer filter layout of raw data from `DC1394FrameGrabber` and `FlyCaptureFrameGrabber` * Readded to `KDTree`, `Index`, and `HOGDescriptor` some functions with `FloatPointer` and `IntPointer` arguments that were mistakenly removed when OpenCV switched to using `cv::InputArray` and `cv::OutputArray` parameter types (issue #134) * Renamed `ProjectiveGainBiasTransformer` to `ProjectiveColorTransformer` * Added a few classes to do some processing using OpenCL and OpenGL: `JavaCVCL`, `GNImageAlignerCL`, `ProjectiveTransformerCL`, `ProjectiveColorTransformerCL`, and `ProCamTransformerCL` with some other related files * Renamed `Parallel.numCores` to the more conventional `Parallel.NUM_CORES` * Added new `FaceRecognition.java` sample from Stephen L. Reed * Inserted a couple of missing calls to `Loader.load()` (issue #142) * Improved hacks for `Loader.load()` in JavaCPP make JavaCV work on Android 4.0 * New `PS3EyeFrameGrabber` from Jiri Masa can now grab images using the SDK from Code Laboratories ===October 1, 2011=== * Fixed `DC1394FrameGrabber` and `FlyCaptureFrameGrabber` to behave as expected with all Bayer/Raw/Mono/RGB/YUV cameras modes (within the limits of libdc1394 and PGR FlyCapture) (issue #91) * Fixed regression of `IplImage.copyFrom()` and `createFrom()` with `BufferedImage` objects of `SinglePixelPackedSampleModel` (issue #102) * C++ functions using `std::vector` objects as output parameters now work on Windows Vista and Windows 7 as well ===August 20, 2011=== * Upgraded support to OpenCV 2.3.1 * An output argument of type `cv::Mat` or `cv::OutputArray` returned with a size 0 now correctly sets `CvArr.address = 0` * Fixed `IplImage.createFrom()` and `copyFrom()` when called on objects returned by `BufferedImage.getSubimage()` * Added missing allocator to `CvRNG` * `OpenCVFrameGrabber` now detects when CV_CAP_PROP_POS_MSEC is broken and gives up calling `cvGetCaptureProperty()` * New `OpenKinectFrameGrabber.grabDepth()` and `grabVideo()` methods to capture "depth" and "video" simultaneously, regardless of the mode ===July 5, 2011=== * Upgraded support to OpenCV 2.3.0 * Fixed `OpenKinectFrameGrabber`, which can now also capture depth images when `setFormat("depth")` is called before `start()` * Fixed `CvMatArray` and `IplImageArray` as well as histogram related functions * Fixed `FFmpegFrameGrabber`, and `FFmpegFrameRecorder` now works on Android also * Fixed calls, such as `opencv_flann.Index.knnSearch()`, that require a `MatAdapter` or an `ArrayAdapter` for output ===June 10, 2011=== * New `freenect` wrapper and corresponding `OpenKinectFrameGrabber` to capture from Microsoft's Kinect stereo camera using OpenKinect * JavaCV now exposes all C++ functions and classes of OpenCV not covered by the C API * Fixed various erroneous declarations and calls, including those due to changes in JavaCPP ===May 11, 2011=== * Removed `CvMat` object pooling in favor of more efficient `ThreadLocal` objects created by `CvMat.createThreadLocal()` * Changed `Marker.getCenter()` back to the centroid, because it has better noise averaging properties and gives in practice more accurate results than the actual center * Added hack to `OpenCVFrameGrabber.start()` to wait for `cvRetrieveFrame()` to return something else than `null` under Mac OS X * FFmpeg now works properly on Windows and Android (issue #63) with newer binaries * New `videoInputLib` wrapper and corresponding `VideoInputFrameGrabber` to capture using DirectShow, useful under Windows 7 where OpenCV and FFmpeg can fail to capture using Video for Windows (issue #58) * `GeometricCalibrator` now reports the maximum errors in addition to the average (RMS) errors ===April 7, 2011=== * Added a `format` property to `CameraDevice`, `FrameGrabber`, and `FrameRecorder`, mostly useful for `FFmpegFrameGrabber`, where interesting values include "dv1394", "mjpeg", "video4linux2", "vfwcap", and "x11grab" * `OpenCVFrameRecorder` now uses `CV_FOURCC_PROMPT` under Windows as default since `CV_FOURCC_DEFAULT` crashes (issue #49) * Added hack to make sure the temporarily extracted library files get properly deleted under Windows * JavaCPP now loads classes more lazily * Fixed most occurences of `UnsatisfiedLinkError` (issue #54), but some corner cases may require a call to `Loader.load()` on the class one wishes to use * Added (rudimentary) outlier detection and modified zero threshold handling in the image alignment framework * New `JavaCV.hysteresisThreshold()` feature * New `HandMouse` functionality, which depends on the image alignment framework * Fixed `ProjectiveDevice.distort()`, which mistakenly undistorted images instead * New `HoughLines` sample thanks to Jeremy Nicola ===February 19, 2011=== * Switched from JNA to JavaCPP, which has a lower overhead and supports C++, bringing hope that future versions of JavaCV will support features of OpenCV available only through the C++ API * Consequently, the syntax of various operations have changed a bit, but the transition should not be too painful * As a happier consequence, this also fixes the problem with SSE instructions on 32-bit x86 (issue #36) * Also, JavaCPP does not have any limitations or performance issues with large data structures (issue #10 and issue #14) * Added support for OpenCV 2.2 (issue #42), but dropped support for all previous versions * Added samples provided by users (issue #1, issue #45, and issue #46) * Added deinterlace setting to `FFmpegFrameGrabber` having it call `avpicture_deinterlace()` (issue #38) * Enhanced a few things of the image alignment algorithm * Tried to fix image format conversion inside `FlyCaptureFrameGrabber`, but this is going to require more careful debugging * Fixed and added various other things I forget ===December 2, 2010=== * Now works on Android with the Dalvik VM (for more details, please refer to the FacePreview sample available on the download page) * Added more hacks to `CanvasFrame` in the hope to make it behave better outside the EDT * Made clearer the error messages thrown from `FrameGrabber` objects, when `start()` may not have been called * Fixed version specific declarations of `CvStereoBMState` and related functions * Fixed conditions that could crash `cvkernels` ===November 4, 2010=== * Renamed the package namespace to `com.googlecode.javacv`, which makes more sense now that JavaCV has been well anchored at Google Code for more than a year, piggybacking on the unique and easy-to-remember domain name * Included new FFmpeg wrapper classes `avutil`, `avcodec`, `avformat`, `avdevice`, `avfilter`, `postprocess`, and `swscale`, eliminating the need of the separate FFmpeg-Java package * `CanvasFrame` now redraws its `Canvas` after the user resizes the `Frame` * Fixed the `Error` thrown when calling `CanvasFrame.showImage()` from the EDT * Added check to `DC1394FrameGrabber` so that a "Failed to initialize libdc1394" does not crash the JVM * `FFmpegFrameGrabber` does not crash anymore when forgetting to call `start()` before a `grab()` or `trigger()` * `FrameGrabber` now selects the default grabber a bit better * Made sweeping changes (for the better, but still not finalized) to `GNImageAligner`, `ProjectiveTransformer`, `ProjectiveGainBiasTransformer`, and `ProCamTransformer`... * Added to `JavaCV` more methods related to transformation of planes: `perspectiveTransform()`, `getPlaneParameters()`, `getPerspectiveTransform()`, and `HtoRt()`, as well as `ProjectiveDevice.getFrontoParallelH()` * Added a static `autoSynch` flag to all `Structure` classes of `cxcore`, `cv`, and `cvaux`, which you may set to `false` prior to the return of things like big and heavy `CvSeq` to make them load faster and to avoid stack overflows, but accessing fields will then require manual calls to `readField()` and `writeField()` (issue #10 and #14) * Added missing `ByValue` subclasses to `CvSeq`, `CvSet`, `CvContourTree`, and `CvChain`... Any others missing? * Fixed `Exception` thrown from `cvCreateHist()` under JNA 3.2.7 (issue #26) * Enhanced `CvMat.put()`, which now supports setting submatrices * Improved inside `IplImage` the support of `BufferedImage`, especially those using a `DirectColorModel` (issue #23) * Fixed crash in `cvkernels` when color transformation `X` is `null` ===July 30, 2010=== * Fixed crash that would occur in `CanvasFrame` for some video drivers * `FFmpegFrameGrabber` now supports other input formats (devices), such as `x11grab` that can be used for screencasting * Added `JavaCV.median()` function, and `JavaCV.fractalTriangleWave()` now respects image ROI * Fixed background subtraction in `cvaux` * Fixed crash inside the code for direct alignment caused by the ROI getting set outside the image plane * Added `deltaScale` and `tryToFixPlane` to `GNImageAligner.Settings` (the first used in `ImageTransformer.Parameters` as increment, randomly selected forward or backward, for finite difference), which sometimes help to jump over local minima ===May 30, 2010=== * Removed redundant `CvMemStorage.clearMem()` method, use `cvClearMemStorage()` * Fixed the sample `Test2` class that did not work under Windows * Fixed corruption by the `cvkernels` `transformer` at the borders * Modified `CanvasFrame` constructors and added a `gamma` argument used by `showImage(IplImage)` * `CanvasFrame` now lets users resize the frame, while displayed images are stretched to fit the new size * Renamed `CanvasFrame.acquireGraphics()` to `createGraphics()` for consistency * When `FlyCaptureFrameGrabber` cannot set fastest speed, it now safely fails by setting any supported speed * Added a new `Parallel.loop()` method that can use more threads than the number of CPU cores detected * Added new `numThreads` property to `GNImageAligner` and fixed a few minor inconsistencies as well * Fixed incorrect `Java.HnToRt()`, and added a few `norm()` and `randn()` methods * For functions with `float[]` and `double[]` arguments in `cvaux` and `cv`, added complementary `FloatBuffer` and `DoubleBuffer` declarations * Fixed loading problems with `cvaux` * Fixed and enhanced histogram, back projection, and other CAMSHIFT related functionality * Added code for `CvRNG` * Added "/opt/local/lib/" and "/opt/local/lib64/" (standard on Mac OS X) to the default list of search paths for OpenCV * Added `CvScalar.getVal()` and `CvIntScalar.getVal()`, which simply return the `val` field, convenient for Scala where `val` is a reserved word * Fixed the construction of `IplImage` from a `Pointer` * Removed incorrect cases when an `IplImage` gets converted to a `BufferedImage.TYPE_CUSTOM` * Made `CvArr.PointerByReference` a bit more consistent and general ===April 16, 2010=== * Modified `IplImage`, `FrameGrabber`, and `CanvasFrame` to get better default behavior of gamma correction * Fixed `cv.CvHistogram` and related histogram functions * `CameraDevice.Settings.triggerFlushSize` now defaults to 5 (only affects `OpenCVFrameGrabber` and `FFmpegFrameGrabber`) * Replaced `LMImageAligner` by `GNImageAligner`, a more appropriate name for Gauss-Newton with `lineSearch` * Fixed a few things related with `ProjectiveDevice.Settings` ===April 8, 2010=== * Added support for OpenCV 2.1 ===April 5, 2010=== * Fixed up `clone()` methods to avoid the need to cast * Removed the `fullScreen` argument from `CanvasFrame` constructors, which will now switch to full-screen mode only when a `screenNumber` is explicitly passed * Renamed `FrameGrabber.ColorMode.GRAYSCALE` to `GRAY` * Replaced deprecated functions from `FFmpegFrameGrabber` and `FFmpegFrameRecorder` * `FFmpegFrameGrabber` can now resize images ===March 21, 2010=== * Added new classes and methods used by ProCamTracker: `cvkernels`, `JavaCV.fractalTriangleWave()`, `ImageAligner`, `LMImageAligner`, `ImageTransformer`, `ProjectiveTransformer`, `ProjectiveGainBiasTransformer`, `ProCamTransformer`, and `ReflectanceInitializer` * `CameraDevice.Settings` has a new `deviceFile` property (used by a `FrameGrabber`), which brings up a file dialog for some `PropertyEditor`s * Moved in `CameraSettings`, `ProjectorSettings`, and `FrameGrabber.PropertyEditor` from the `procamcalib` package * Added to `CameraDevice.Settings` and `FrameGrabber` a `triggerFlushSize` property to indicate the number of buffers to flush on `trigger()` to compensate for cheap cameras that keep old images in memory indefinitely * Changed the type of `CameraDevice.Settings.deviceNumber` to `Integer` so we may set it to `null` * Fixed and enhanced `CanvasFrame.showImage()` methods a bit * In `triggerMode` `DC1394FrameGrabber` now tries to use a real software trigger and only falls back to one-shot mode on error * Fixed array constructors of `IplImage.PointerByReference()` and `CvImgObsInfo.PointerByReference()` * Added `CvPoint.fillArray()` methods to reuse preallocated arrays and changed `createArray()` a bit as well * Fixed and enhanced all `IplImage.copy*()` methods, including new support for ROIs and subimages, which affects `create*()` and `getBufferedImage()` methods as well * Updated `Marker` to support different size and spacing in X and Y * Added `Settings` to `ObjectFinder` * Fixed distortion problem in `ProjectiveDevice` and `ProCamColorCalibrator` with OpenCV 1.1pre1 * Split `ProjectiveDevice.Settings` into `ProjectiveDevice.CalibrationSettings` (for applications like ProCamCalib) and `ProjectiveDevice.CalibratedSettings` (for applications like ProCamTracker) * Renamed `gamma` to `responseGamma` in `ProjectiveDevice`, and moved previous `nominalDistance` parameter to `Settings` * Added `ProjectiveDevice.rescale()` to rescale calibration parameters when switching a device to a new image size * `ProjectiveDevice.undistort()` and `distort()` can now `useFixedPointMaps` of OpenCV * `ProjectiveDevice` and its subclasses now `throw new Exception()` if the `parameterFile` cannot be read ===February 13, 2010=== * Relicensed JavaCV under the GPLv2 with Classpath exception (see LICENSE.txt). Please note that if your application links with code that needs ARToolKitPlus, for example, it will become subject to the full GPL, without Classpath exception * Added `devicePath` setting to `CameraDevice` that works with `FFmpegFrameGrabber`, `OpenCVFrameGrabber`, and other `FrameGrabber` with a String constructor * Added "C:/OpenCV2.0/bin/release/" to the directory list to search for OpenCV DLLs * Moved `cvFindHomography()`, `cvFindExtrinsicCameraParams2()`, `cvReprojectImageTo3D()`, `cvSaveImage()`, and `cvRetrieveFrame()` to version specific classes since their number of arguments differ with the version of OpenCV * Enhanced `CvMat.put(CvMat mat)` to work better even when the matrices are not actually compatible * Added new `IplImage` factory methods `createCompatible(IplImage image)`, `createIfNotCompatible(IplImage image, IplImage template)`, and `createFrom(BufferedImage image)` * Fixed `distortionCoeffs` corruption that might occur in `ProjectiveDevice` ===January 3, 2010=== * Added wrapper for the `cvaux` module of OpenCV * Added abstract `FrameRecorder` class and a `OpenCVFrameRecorder` class * Fixed read() problem that might occur within Pointer constructors * Running `java -jar javacv.jar` now displays version information ===December 22, 2009=== * Fixed `CanvasFrame` from getting stuck in a maximized window * Removed all `setAutoWrite(false)` from `cxcore` now that the bug appears fixed in JNA * Added `FFmpegFrameGrabber` and `FFmpegFrameRecorder` to easily record live footage and grab back offline into JavaCV ===November 24, 2009=== * Added more convenient constructors and factory methods for `CvPoint*`, `CvSize*`, `CvRect`, `CvTermCriteria`, `CvSlice`, and `CvAttrList` * Added _R2_ correlation coefficient field to `ProjectiveDevice` * Enhanced and fixed color conversion spaghetti code in `FlyCaptureFrameGrabber` * Fixed the `CvHaarFeature` Structure * Renamed `CvIntScalar` factory methods to match with `CvScalar` * Enhanced and fixed some problems with gamma correction in `IplImage` * Added a `highgui.CV_FOURCC()` method that takes chars as parameter * Moved `MarkedPlane.drawMarkers()` to `Marker.draw()` for better code reuse * Added `MarkedPlane.getTotalWarp()` with a "useCenters" parameter * Changed default values of `MarkerDetector.binarizationKWhiteMarkers` to 1.0 and `ProjectorDevice.brightnessBackground` to 0.0 * Fixed issue with image width and memory alignment in `MarkerDetector` * `Marker.getCenter()` now computes the actual physical center instead of the centroid * `OpenCVFrameGrabber.getDeviceDescriptions()` now throws `UnsupportedOperationException` * Added support in `OpenCVFrameGrabber` to grab frames from video files * Added `ProjectiveDevice.getRectifyingHomography()` method * Added `JavaCvErrorCallback` to easily catch errors of OpenCV in Java ===October 19, 2009=== * Moved the functionality of `CvMatPool` to the `CvMat.take()` and `.pool()` methods * Added color calibration for projector-camera systems (`ProCamColorCalibrator`) * Updated `DC1394FrameGrabber` to handle more conversion use cases automatically * Fixed `CvIntScalar` to mirror `CvScalar` ===October 14, 2009=== * Change of plan: JavaCV now works with any of OpenCV 1.0, 1.1pre1, or 2.0! Version specific functionality is enclosed in subclasses, e.g., the class `cv.v20` can access everything from the `cv` module of OpenCV 2.0 * Added a few missing functions and adjusted some mappings to make them closer to the C API * Added a few more helper methods to `CvPoint*` * Added temporary storage to `ObjectFinder` to plug the memory leak ===October 2, 2009=== * Fixed problem when loading distortion coefficients with `ProjectiveDevice` * Added automatic read and write for functions with arrays of `Structure` or `PointerByReference` * Added to `cv.java` a few missing functions related to calibration * Fixed up a bit helper methods for `CvPoint*`, `CvScalar`, `CvRect`, `CvBox2D`, `CvMat`, `IplImage`, `CvMemStorage`, `CvSeq`, and `CvSeqBlock` * Added `CvMatPool` to `MarkedPlane` and `Marker` * Added a few new `distort()` methods to `ProjectiveDevice` * Last version to support OpenCV 1.1pre1: Future version will require OpenCV 2.0 ===August 27, 2009=== * `IplImage` now flips the buffer on copy if necessary * Added needed Pointer constructor for `CvSURFPoint` and `CvConvexityDefect` * Cleaned up a bit the messy Buffers in `CvMat` ===August 26, 2009=== * Added `get*Buffer()` functions to `IplImage` * Added more options for gamma correction in `IplImage` and `ProjectiveDevice` * Further cleaned up the namespace and constructors of `ProjectiveDevices` * `CanvasFrame.waitKey()` now only checks `KeyEvent.KEY_PRESSED` * Added `CvMatPool` to avoid recreating matrices * Moved `CvScalar` functions to `cxcore` ===August 19, 2009=== * Switched to using `import static` for relief from namespace hell * Fixed color channel reversal of Bayer images in `DC1394FrameGrabber` ===August 11, 2009=== Initial release ---- Copyright (C) 2009-2014 Samuel Audet <[email protected]> Project site: http://code.google.com/p/javacv/ Licensed under the GNU General Public License version 2 (GPLv2) with Classpath exception. Please refer to LICENSE.txt or http://www.gnu.org/licenses/ for details.
Hi Samuel,
Congrats for such a great tool!
On my project, I need to pass a webcam image that I am controlling with a non
javacv controller, onto javacv to extract the face only (face detector), and
return that reduced image back to my main project. For this, I am passing a
BufferedImage from my
project to my javaCV module, and then I need to convert it to IplImage to do
all the
processing. However, the conversion from BufferedImage to IpllImage,
as I saw online doesn't seem to work, and I wonder what am I doing
wrong? Here is what I'm doing:
public BufferedImage doFaceDetection(BufferedImage origbffimg)
{
...
IplImage grabbedImage = IplImage.createFrom(origbffimg);
... (do processing, and return the chopped BufferedImage of my face)
}
It does not crash, and it compiles no errors, but it seems to be
failing to do a proper conversion at: IplImage grabbedImage =
IplImage.createFrom(origbffimg);
In fact, I tried a very simple example, to make sure that my problem
was on the conversion part:
public void dumbTest(BufferedImage a)
{
IplImage b = IplImage.createFrom(a); //convert BufferedImage "a" into IplImage "b"
BufferedImage c = b.getBufferedImage(); // convert IplImage "b" from previous step, back into a BufferedImage "c"
// "c" should be the same as "a", but when debugging stepping into, I realised
they were not!
}
1. What might I be doing wrong?
2. An additional short question: I eliminated the random rotaion of
the plane you were performing on your sample. However, I am not allowed to
remove the
cvRodrigues2(randomAxis2, randomR2, null) function. If I remove it,
then it crashes on Runtime at: CvHaarClassifierCascade cascade = new
CvHaarClassifierCascade(cvLoad(cascadeName));
Any idea why, since anyway now I'm not using neither randomAxis2 nor
randomR2? Otherwise, how can I safely eliminate all the random plane
rotation part?
Many thanks, and keep the hard work for such a great tool! :)
What steps will reproduce the problem?
1. IplImage b = IplImage.createFrom(a); //convert BufferedImage "a" into
IplImage "b"
2. BufferedImage c = b.getBufferedImage(); // convert IplImage "b" from
previous step, back into a BufferedImage "c"
What is the expected output? What do you see instead?
// From the above code, I would expect "c" to be the same as "a", but when
debugging stepping into, I realised they were not!
What version of the product are you using? On what operating system?
OS: Tried it on a Windows 7 machine, JavaCV binary package (2010-07-30)
Please provide any additional information below.
Many thanks!
Original issue reported on code.google.com by [email protected]
on 25 Sep 2010 at 9:05
What steps will reproduce the problem?
1. Install javacv (and prerequirements) on a Mac
2. Try the Demo.java example given on the javacv homepage
3. This seems to work fine, and at the end it creates an "output.avi" file.
However, when you open this file, it seems to be corrupted. It does play, but
it looks very odd with bright and dark horizontal lines, duplications, strange
colours, etc, and the speed is by far quicker than it should be (hence, less
duration).
Problem 1 (odd display) may have to do with codecs? However, I tried installing
many codecs, or moving the video to another machine that has pretty much all
popular codecs, and it looks the same everywhere. I tried modifying the
encoding format used, but the OpenCVFrameRecorder does not allow to modify the
"codecID", which has it set to CV_FOURCC_DEFAULT. For this reason, I created my
own OpenCVFrameRecorderVersion2, and tried using CV_FOURCC('D','I','V','X') or
CV_FOURCC('P','I','M','1'), etc, but none work fine. Then I tried to run it on
a Windows machine that has all the popular codecs installed, but the current
javacv version crashes at line "Loader.load(opencv_objdetect.class);" of the
website example, as stated in another Issue opened.
Problem 2 (too quick movie recorded with short duration) may have to do with
the "this.frameRate = 30" bit of OpenCVFrameRecorder, which cannot be modified
either (unless I create my own OpenCVFrameRecorderVersion2 class)? Perhaps by
modifying that value it takes more frames per sec, and becomes closer to
real-time?
What is the expected output? What do you see instead?
To have an output.avi video that represent very well what I did in front of the
webcam, in terms of display and speed, but I get a video with bright and dark
horizontal lines, duplications of my face, odd colours, and very very high
speed (short duration), likely because very few frames were grabbed when
recording.
What version of the product are you using? On what operating system?
Latest version, on a Mac OS X (Snow Leopard)
Please provide any additional information below.
Sidenote question: would javacv allow to record both audio and visual channel
simmultaneously, so that I can hear me speaking while running output.avi, or
even a separate but synchronised .wav file?
Many thanks!
Steve
Original issue reported on code.google.com by [email protected]
on 23 Feb 2011 at 6:49
Its not a Problem, but a Question. Related to FFmpegFramegrabber Class.
Short Version: How can I use a function like this:
DeprecatedFunctions.avpicture_deinterlace(dst, src, pix_fmt, width, height);
This Function is "Deprecated". What is current workaround when I have
interlaced video material? How can I deinterlace the picture within the
FFmpegFramegrabber class?
What version of the product are you using? On what operating system?
Win7 64bit
OpenCv 2.1.0
Original issue reported on code.google.com by [email protected]
on 9 Dec 2010 at 10:59
What steps will reproduce the problem?
1. Running the calibration
2. The entire calibration is done normally, when the last capture is done the
error occurs.
What is the expected output? What do you see instead?
Expected to get the calibration matrices. Instead the calibration fails and
returns the error below.
Please provide any additional information below.
I am using windows 7, but i'm running all 32-bit software.
The error is reported as follows in NetBeans:
Sep 15, 2010 9:00:25 PM name.audet.samuel.procamcalib.CalibrationWorker
doInBackground
SEVERE: Could not perform calibration
java.lang.Exception: flycaptureConvertImage() Error 2
at name.audet.samuel.javacv.FlyCaptureFrameGrabber.grab(FlyCaptureFrameGrabber.java:411)
at name.audet.samuel.javacv.FrameGrabber$Array.grab(FrameGrabber.java:238)
at name.audet.samuel.procamcalib.CalibrationWorker.calibrateColor(CalibrationWorker.java:469)
at name.audet.samuel.procamcalib.CalibrationWorker.doInBackground(CalibrationWorker.java:234)
at javax.swing.SwingWorker$1.call(SwingWorker.java:277)
at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:303)
at java.util.concurrent.FutureTask.run(FutureTask.java:138)
at javax.swing.SwingWorker.run(SwingWorker.java:316)
at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
at java.lang.Thread.run(Thread.java:619)
Original issue reported on code.google.com by [email protected]
on 15 Sep 2010 at 7:06
Hello Samuel,
Hope you are doing well. I believe I have found a bug in cvGet2D(image, x,y).
It behaves as if the x coordinate is actually the y coordinate. I passed in a
320 x 240 image and as soon as x gets to be 240 it throws an out of range
exception. I've downloaded the latest version and this is still occurring.
Best Regards,
Greg.
P.S. Wow, had a lot of imports to change on that last update :D !
What steps will reproduce the problem?
1.pass in 320 x 240 image
2.when x becomes > 240 error is thrown
What is the expected output? What do you see instead?
return the pixel scalar
What version of the product are you using? On what operating system?
the latest release
Fedora Core 13
Please provide any additional information below.
Original issue reported on code.google.com by [email protected]
on 20 Nov 2010 at 7:22
What steps will reproduce the problem?
1. Attempt to use JavaCV objects (say, create an IplImage) without root access.
What is the expected output? What do you see instead?
One would expect the program to run without issues, creating the IplImage.
The output we get is the following:
Exception in thread "main" java.lang.UnsatisfiedLinkError: Unable to load
library 'highgui': libcv.so.2.1: cannot open shared object file: No such file
or directory
at com.sun.jna.NativeLibrary.loadLibrary(NativeLibrary.java:164)
at com.sun.jna.NativeLibrary.getInstance(NativeLibrary.java:237)
at com.sun.jna.NativeLibrary.getInstance(NativeLibrary.java:200)
at name.audet.samuel.javacv.jna.Loader.load(Loader.java:44)
at name.audet.samuel.javacv.jna.highgui.<clinit>(highgui.java:76)
at com.hid.iod.imageprocessing.HidImage.<init>(TestImage.java:77)
The exact line where it fails is:
originalImage = cvLoadImage(location);
This is the first line in my code which summons a JavaCV object
What version of the product are you using? On what operating system?
I am using Java 1.6, JDK 6, OpenCV 2.1.0, JNA 3.2.5, and JavaCV 20100730. This
is on RedHat Enterprise Linux Server Release 5.5 (Tikanga).
Please provide any additional information below.
The opencv libraries are in /usr/local/lib64/, which has chmod 777 (rwx for
all).
Original issue reported on code.google.com by [email protected]
on 28 Dec 2010 at 7:37
What steps will reproduce the problem?
1. Simply run Test2.java on the javacv home page.
I am expecting a frame with a webcam(attached to my PC) image generated.
It returns an error below :
--------------------------------------------------------------------------
Exception in thread "main" java.lang.IllegalArgumentException: Width (0) and
height (0) cannot be <= 0
at java.awt.image.DirectColorModel.createCompatibleWritableRaster(DirectColorModel.java:999)
at sun.awt.image.SunVolatileImage.getBackupImage(SunVolatileImage.java:207)
at sun.awt.image.VolatileSurfaceManager.getBackupSurface(VolatileSurfaceManager.java:235)
at sun.awt.image.VolatileSurfaceManager.initialize(VolatileSurfaceManager.java:91)
at sun.awt.image.SunVolatileImage.<init>(SunVolatileImage.java:58)
at sun.awt.image.SunVolatileImage.<init>(SunVolatileImage.java:67)
at sun.awt.image.SunVolatileImage.<init>(SunVolatileImage.java:78)
at sun.awt.image.SunVolatileImage.<init>(SunVolatileImage.java:72)
at sun.awt.windows.WComponentPeer.createVolatileImage(WComponentPeer.java:501)
at java.awt.Component.createVolatileImage(Component.java:3021)
at java.awt.Component$BltBufferStrategy.createBackBuffers(Component.java:3558)
at java.awt.Component$BltBufferStrategy.<init>(Component.java:3544)
at java.awt.Component.createBufferStrategy(Component.java:3264)
at java.awt.Canvas.createBufferStrategy(Canvas.java:166)
at java.awt.Component.createBufferStrategy(Component.java:3204)
at java.awt.Canvas.createBufferStrategy(Canvas.java:141)
at name.audet.samuel.javacv.CanvasFrame.init(CanvasFrame.java:173)
at name.audet.samuel.javacv.CanvasFrame.<init>(CanvasFrame.java:111)
at name.audet.samuel.javacv.CanvasFrame.<init>(CanvasFrame.java:107)
at Test2.main(Test2.java:16)
--------------------------------------------------------------------------
Using latest javacv.jar & jna.jar on windows xp. Using eclipse.
I am using JDK 1.5 update 21
Original issue reported on code.google.com by [email protected]
on 12 Oct 2010 at 6:24
What steps will reproduce the problem?
Hello Samuel,
I have been experimenting with cvFindContours & cvApproxPoly.
I have noticed when the polygon count is greater than 18(ish) it will take >
10 seconds to process. I don't seem to get the same behavior in a similar .c
program. I was guessing this had to do with the amount of data transported
through the jna call. 6 Polygons require ~1 second. This makes "real time"
processing a bit of a challenge.
I was initially hoping to filter some of the polygons out based on area, but
noticed cvContourArea is commented out. Was this intentional?
I suspect that this is not a problem with the your great code, but just an area
where OpenCV has a significant amount of data being processed as return values
or passed with pointers, and the JNA wrapper incurs a significant performance
loss.
With that in mind I was wondering what you might recommend as a strategy? The
amount of data when you isolate the polygons you are interested in is
surprisingly sparse. For example, I am only interested resulting bounding
perimeter and centroid which consists of a few points. The problem is, to get
there, a large amount of data needs to be passed back and forth.
I could write my own blob function in c and jna wrap that with minimal data
exchange. I believe they have done that at OPENCV
(http://ubaa.net/shared/processing/opencv/). This works, but seems rather
fragile in the long run. It would need to be maintained, remain compatible
with Linux, Windows, Mac, remain compatible with opencv releases.. etc... etc...
I wish opencv had a blob function with a variety of parameters and a simple
(lean) data structure passed back. Alas, there seems to be a considerable
amount of disparity in the subject. The blobslib must be separately downloaded
from opencv and other have similar projects have sprung up (e.g.
http://code.google.com/p/cvblob/)
I guess after rambling on for a while, the best long term solution would be to
extend your JNA code to wrap the blobslib from opencv. Is this of interest to
you?
I will start looking into the details.
Best Regards,
Greg.
Original issue reported on code.google.com by [email protected]
on 11 Jul 2010 at 2:46
What steps will reproduce the problem?
1.import static com.googlecode.javacv.jna.cv.v20.cvCalcImageHomography;
2.call cvCalcImageHomography in java code
3.
What is the expected output? What do you see instead?
"Exception in thread "main" java.lang.UnsatisfiedLinkError: Unable to load
library 'cv': ÕҲ»µ½ָ¶¨µÄģ¿顣" <-- Unrecognizable message.
What version of the product are you using? On what operating system?
opencv 2.1, windows xp
Please provide any additional information below.
I didn't find cvCalcImageHomography in "cv" but found it in "cv.v20", "cv.v10"
and "cv.v11", so I tried invoking them but got above exception. Does it mean
cvCalcImageHomography is not supportted in v21? And the same to function
cvFindHomography.
Original issue reported on code.google.com by [email protected]
on 31 Jan 2011 at 6:33
Also, in an attempt to do a workaround, discovered cvCopy appears to be missing
as well.
Original issue reported on code.google.com by [email protected]
on 16 Jul 2010 at 9:00
Hi Samuel,
Is Flann in JavaCV? I was looking at cv and cvcore and didn't find them
Thanks!
Original issue reported on code.google.com by [email protected]
on 15 Oct 2010 at 6:53
What steps will reproduce the problem?
1. Add the Jar files to the project in Eclipse.
2. The project will compile and begin to run just fine.
3. The first JavaCV statement it reaches will cause it to crash saying, "The
source attachment does
not contain the source for the file Loader.class."
What is the expected output? What do you see instead?
I expect it to run over the line of code: new
JavaCvErrorCallback().redirectError();
Instead, it crashes.
What version of the product are you using? On what operating system?
I am using the most recent version as of 5:07 PST on Tuesday, May 4, 2010. I am
running Mac OS
X 10.6.3.
Please provide any additional information below.
When I downloaded the link you had for jna.jar, it gave me a folder called
jna.jar instead of a jar
file. I then went into the folder with all the classes and used the manifest
file to create a new jar. I
used that new jar as my jna.jar file.
I also added the javacv.jar, ffmpeg-java.jar, procamlib.jar, and
procamtracker.jar files, even
though I am not using a camera. I am decoding a byte array. The code compiles
just fine. I am
not sure what else you would need from me. Thank you.
Original issue reported on code.google.com by [email protected]
on 5 May 2010 at 12:13
What steps will reproduce the problem?
1. Running the code sample provided
public class ExampleDifference {
public static void main(String[] args) {
new JavaCvErrorCallback().redirectError();
// memoryLeakExample();
slowDownExample();
}
// In this example we are reusing the CvMemStorage object (but NOT calling
// cvClearMemStorage).
//
// In this case after 20,000 iterations the time per iteration has doubled
// from 6ms to 11ms however the memory usage has remained stable throughout
// at only around 20MB
//
private static void slowDownExample() {
String imageFile = "test.png";
IplImage image = cvLoadImage(imageFile, CV_LOAD_IMAGE_GRAYSCALE);
IplImage edge = IplImage.create(image.width, image.height, image.depth,
image.nChannels);
cvCanny(image, edge, 1000, 1200, 3);
CvMemStorage mem = CvMemStorage.create();
long totalTime = 0;
int iteration = 0;
while (true) {
iteration++;
long start = System.currentTimeMillis();
CvSeq hough = cvHoughLines2(edge, mem.getPointer(),
CV_HOUGH_STANDARD, 1, Math.PI
/ TuningParameter.houghAnalysisResolution, 1000, 0,
0);
long end = System.currentTimeMillis();
long time = end - start;
totalTime += time;
if (iteration % 100 == 0) {
System.out.println("Iteration - " + iteration
+ " average time per iteration " + (totalTime / 100));
totalTime = 0;
}
}
}
// In this case, after 20,000 iterations the time per iteration remains
// stable (at 7ms on my box), but the memory usages has increased
// continuously to 180MB
//
private static void memoryLeakExample() {
String imageFile = "test.png";
IplImage image = cvLoadImage(imageFile, CV_LOAD_IMAGE_GRAYSCALE);
IplImage edge = IplImage.create(image.width, image.height, image.depth,
image.nChannels);
cvCanny(image, edge, 1000, 1200, 3);
long totalTime = 0;
int iteration = 0;
while (true) {
iteration++;
long start = System.currentTimeMillis();
CvMemStorage mem = CvMemStorage.create();
CvSeq hough = cvHoughLines2(edge, mem.getPointer(),
CV_HOUGH_STANDARD, 1, Math.PI
/ TuningParameter.houghAnalysisResolution, 1000, 0,
0);
cvClearMemStorage(mem);
mem.release();
cvReleaseMemStorage(mem.pointerByReference());
long end = System.currentTimeMillis();
long time = end - start;
totalTime += time;
if (iteration % 100 == 0) {
System.out.println("Iteration - " + iteration
+ " average time per iteration " + (totalTime / 100));
totalTime = 0;
}
}
}
}
What is the expected output? What do you see instead?
See comments for detail. In the first case I see a slow down over time, in the
second case I see a memory leak
What version of the product are you using? On what operating system?
- Lastest precompiled dlls for OpenCV 2.1.0
- Window 7 64bit
Please provide any additional information below.
Original issue reported on code.google.com by [email protected]
on 14 Jan 2011 at 3:55
What steps will reproduce the problem?
1. Install all prerequired software as instructed in the website
2. Create a java project and add the Demo.java example provided in the javacv
homepage
3. Add all the javacv jar libraries (Netbeans)
4. Run/Debug the project -> it crashes at Loader.load(opencv_objdetect.class);
What is the expected output? What do you see instead?
Not to crash. I have everything installed, I have tried older versions in the
past that run on this machine (when it used name.audet.samuel.javacv.jna...
instead of com.googlecode.javacv.cpp...
(by the way, notice the missing semi-colon at line "import
com.googlecode.javacv.cpp.*" if you would like to correct it
What version of the product are you using? On what operating system?
Latest version, downloaded today. Windows 7. However, it seems to run fine on a
Mac, but that the video recorded seems to be wrongly encoded and looks very odd
(but I guess this is a separate issue I can open in another thread).
Please provide any additional information below.
It compiles fine, but it crashes at:
Loader.load(opencv_objdetect.class);
Information:
Exception in thread "main" java.lang.UnsatisfiedLinkError:
C:\Users\myuser\AppData\Local\Temp\jniopencv_core1024071573664674187.dll: Can't
find dependent libraries
at java.lang.ClassLoader$NativeLibrary.load(Native Method)
at java.lang.ClassLoader.loadLibrary0(ClassLoader.java:1803)
at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1699)
at java.lang.Runtime.load0(Runtime.java:770)
at java.lang.System.load(System.java:1003)
at com.googlecode.javacpp.Loader.load(Loader.java:308)
at com.googlecode.javacpp.Loader.load(Loader.java:258)
at com.googlecode.javacv.cpp.opencv_core$CvPoint.<clinit>(opencv_core.java:1733)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:169)
at com.googlecode.javacpp.Loader.load(Loader.java:280)
at com.googlecode.javacpp.Loader.load(Loader.java:258)
at com.googlecode.javacv.cpp.opencv_core$CvSize.<clinit>(opencv_core.java:2047)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:169)
at com.googlecode.javacpp.Loader.load(Loader.java:280)
at com.googlecode.javacpp.Loader.load(Loader.java:258)
at com.googlecode.javacv.cpp.opencv_core$CvScalar.<clinit>(opencv_core.java:2151)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:169)
at com.googlecode.javacpp.Loader.load(Loader.java:280)
at com.googlecode.javacpp.Loader.load(Loader.java:258)
at com.googlecode.javacv.cpp.opencv_core$CvErrorCallback.<clinit>(opencv_core.java:3962)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:169)
at com.googlecode.javacpp.Loader.load(Loader.java:280)
at com.googlecode.javacpp.Loader.load(Loader.java:258)
at com.googlecode.javacv.cpp.opencv_core.<clinit>(opencv_core.java:120)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:169)
at com.googlecode.javacpp.Loader.load(Loader.java:280)
at com.googlecode.javacv.cpp.opencv_imgproc.<clinit>(opencv_imgproc.java:87)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:169)
at com.googlecode.javacpp.Loader.load(Loader.java:280)
at com.googlecode.javacv.cpp.opencv_highgui.<clinit>(opencv_highgui.java:88)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:169)
at com.googlecode.javacpp.Loader.load(Loader.java:280)
at com.googlecode.javacv.cpp.opencv_objdetect.<clinit>(opencv_objdetect.java:85)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:169)
at com.googlecode.javacpp.Loader.load(Loader.java:280)
at javacvvidrec.Demo.main(Demo.java:23)
Java Result: 1
BUILD SUCCESSFUL (total time: 31 seconds)
Original issue reported on code.google.com by [email protected]
on 23 Feb 2011 at 6:33
What steps will reproduce the problem?
1. Create any class which uses MarkerDetector
2. Use an image with marker (or video stream)
What is the expected output? What do you see instead?
- Array of markers which are in the image is expected
- I get an empty array all the time
- So I went and debugged it and I found that marker's id was always -1. So I
commented out the if condition where it checks if (m.id < 0) { continue;}
It then returned correct output.
Original issue reported on code.google.com by [email protected]
on 6 Dec 2010 at 9:39
Hello,
Hope you are doing well.
Yes it now gets past creating the model..
Unfortunately, I get a crash now in cvUpdateBGStatModel (see below). As I said
previously I'm just trying to port over the bgfg_segm.c from the samples.
Hopefully, I'm not out of sync somewhere. I do not want to be wasting your
time.
I can successfully run the bgfg_segm.c sample from an ecllipse cpp debugger.
Is there anything I can do to help?
Below the code is a thread stack dump of the crash.
Regards,
Greg.
CvGaussBGStatModelParams params = new CvGaussBGStatModelParams();
params.win_size=2;
params.n_gauss=5;
params.bg_threshold=0.7;
params.std_threshold=3.5;
params.minArea=15;
params.weight_init=0.05;
params.variance_init=30;
bg_model = v21.cvCreateGaussianBGModel( grey, null );
//bg_model = cvCreateFGDStatModel( temp );
}
v21.cvUpdateBGStatModel(image, bg_model, update_bg_model ? -1 : 0);
Thread Stack @ cvUpdateBGStatModel
Current thread (0x997d3c00): JavaThread "Thread-4" [_thread_in_native,
id=11408, stack(0x05d0f000,0x05d60000)]
siginfo:si_signo=SIGSEGV: si_errno=0, si_code=2 (SEGV_ACCERR),
si_addr=0x99572014
Registers:
EAX=0x00000003, EBX=0x026a1988, ECX=0x99572010, EDX=0x00000001
ESP=0x05d5e5b0, EBP=0x00000005, ESI=0x99571f01, EDI=0x99571fb0
EIP=0x02605dd0, CR2=0x99572014, EFLAGS=0x00010206
Top of Stack: (sp=0x05d5e5b0)
0x05d5e5b0: 3d4ccccd 00000000 00000000 00000000
0x05d5e5c0: 00000000 44610000 00000000 41c80000
0x05d5e5d0: 40800000 42080000 41c00000 42040000
0x05d5e5e0: 40600000 997814cb 00000059 99757d80
0x05d5e5f0: 3f000000 43610000 3f333333 000000a0
0x05d5e600: 00000004 00000140 00000081 9956e810
0x05d5e610: 05d5e85c 000003c0 000000f0 0000c800
0x05d5e620: 00220008 026a1988 000000f0 05d5e7e8
Instructions: (pc=0x02605dd0)
0x02605dc0: 48 8d b4 26 00 00 00 00 89 c1 c1 e1 05 8d 0c 0f
0x02605dd0: d9 41 04 d8 cb d9 51 04 de c2 d9 01 d8 cb d9 19
Stack: [0x05d0f000,0x05d60000], sp=0x05d5e5b0, free space=317k
Native frames: (J=compiled Java code, j=interpreted, Vv=VM code, C=native code)
C [libcvaux.so+0x7bdd0]
Java frames: (J=compiled Java code, j=interpreted, Vv=VM code)
j com.sun.jna.Function.invokeInt(I[Ljava/lang/Object;)I+0
j
com.sun.jna.Function.invoke([Ljava/lang/Object;Ljava/lang/Class;Z)Ljava/lang/Obj
ect;+315
j
com.sun.jna.Function.invoke(Ljava/lang/Class;[Ljava/lang/Object;Ljava/util/Map;)
Ljava/lang/Object;+214
j
com.sun.jna.CallbackReference$NativeFunctionHandler.invoke(Ljava/lang/Object;Lja
va/lang/reflect/Method;[Ljava/lang/Object;)Ljava/lang/Object;+198
j
$Proxy13.callback(Lname/audet/samuel/javacv/jna/cxcore$IplImage;Lname/audet/samu
el/javacv/jna/cvaux$CvBGStatModel;D)I+27
j
name.audet.samuel.javacv.jna.cvaux$v21.cvUpdateBGStatModel(Lname/audet/samuel/ja
vacv/jna/cxcore$IplImage;Lname/audet/samuel/javacv/jna/cvaux$CvBGStatModel;D)I+2
1
j
com.myrobotlab.image.OpenCVFilterFGBG.process(Lname/audet/samuel/javacv/jna/cxco
re$IplImage;Ljava/util/HashMap;)Lname/audet/samuel/javacv/jna/cxcore$IplImage;+1
45
j com.myrobotlab.service.OpenCV$VideoProcessor.run()V+204
j java.lang.Thread.run()V+11
v ~StubRoutines::call_stub
Original issue reported on code.google.com by [email protected]
on 8 Jul 2010 at 2:14
Hi,
Is there a performant method to convert a java.awt.image or an array of
floats or int to an IplImage?
I tried set2D, but it's slow, like 7 seconds for 200x200 on 2GHz.
Original issue reported on code.google.com by [email protected]
on 20 Apr 2010 at 3:58
What steps will reproduce the problem?
Histogram Equalization:
public BufferedImage Equalize(BufferedImage img)
{
IplImage img = IplImage.createFrom(img);
IplImage out = cvCreateImage(cvSize(img.width, img.height), IPL_DEPTH_8U, 1);
// Perform histogram equalization
cvEqualizeHist( out, out );
BufferedImage eqimg = out.getBufferedImage();
out.release();
return eqimg;
}
What is the expected output? What do you see instead?
The returned equalized image "eqimg" is not displayable on my GUI. The "img" I
pass into the function however works fine, but not the returned "eqimg".
What version of the product are you using? On what operating system?
Lastest javacv version, Windows 7.
Please provide any additional information below.
Even if I perform a simple grayscale conversion, it has the same problem:
public BufferedImage GrayConversion(BufferedImage img)
{
IplImage img = IplImage.createFrom(img);
IplImage out = cvCreateImage(cvSize(img.width, img.height), IPL_DEPTH_8U, 1);
BufferedImage grayimg = out.getBufferedImage();
out.release();
return grayimg;
}
Hence, I might be doing something wrong in the following line?:
IplImage out = cvCreateImage(cvSize(img.width, img.height), IPL_DEPTH_8U, 1);
Original issue reported on code.google.com by [email protected]
on 4 Oct 2010 at 11:19
i get the following after creating a file named telda and placing the same code
for test2.....
Exception in thread "main" java.lang.UnsatisfiedLinkError: Unable to load
library 'cxcore': The specified module could not be found.
at com.sun.jna.NativeLibrary.loadLibrary(NativeLibrary.java:163)
at com.sun.jna.NativeLibrary.getInstance(NativeLibrary.java:236)
at com.sun.jna.NativeLibrary.getInstance(NativeLibrary.java:199)
at name.audet.samuel.javacv.jna.Loader.load(Loader.java:44)
at name.audet.samuel.javacv.jna.cxcore.<clinit>(cxcore.java:115)
at name.audet.samuel.javacv.jna.highgui.<clinit>(highgui.java:73)
at name.audet.samuel.javacv.OpenCVFrameGrabber.start(OpenCVFrameGrabber.java:96)
at Telda.main(Telda.java:21)
the thing is that i tried to install it b4 i'm using windows 7 home premium, it
installed and worked, i had to reformat now i don't know what i am missing, i
installed opencv from sourceforge, i added the path to all users.
now i don't know whats the problem,
please help
thank you very very much
Original issue reported on code.google.com by [email protected]
on 26 Jul 2010 at 5:42
What steps will reproduce the problem?
Hi Samuel,
i am trying to find circles using your javacv library. But i'm having trouble
getting it to work. So i thought maybe you could help with some tips :)
I have an image that i convert to grayscale, then smooth it, then find edges
using canny. After that i run cvFindContours and would like to go through the
found contours using cvFitEllipse2 to find its bounding box and calculate by
its height and width if it could be a circle.
The code looks like this. I left parts out because i build a gui around it to
add visual parameter tweaking later:
// Prepare image to detect objects.
IplImage imageToDetectObjects = inputImage.getCopy().getOpenCVImage();
// convert to grayscale
IplImage src = imageToDetectObjects.clone();
int width = src.width;
int height = src.height;
IplImage dst = cvCreateImage(new CvSize(width, height).byValue(), IPL_DEPTH_8U,
1);
cvCvtColor(src, dst, CV_RGB2GRAY);
imageToDetectObjects = dst.clone();
// smooth it, otherwise a lot of false circles may be detected
cvSmooth(imageToDetectObjects, imageToDetectObjects, CV_GAUSSIAN, 9, 9, 2, 2);
// create binary image
IplImage binImage = imageToDetectObjects.clone();
cv.cvCanny(imageToDetectObjects, binImage, 0.3, 0.5, 3);
imageToDetectObjects = binImage.clone();
.
.
.
// find contours
memoryStorage = CvMemStorage.create();
CvSeq.PointerByReference contourPointer = new CvSeq.PointerByReference();
int contourPointerSize =
com.sun.jna.Native.getNativeSize(CvContour.ByValue.class);
CvSeq contourList = new CvSeq();
cvFindContours(imageToDetectObjects, memoryStorage, contourPointer,
contourPointerSize, CV_RETR_LIST, CV_CHAIN_APPROX_SIMPLE);
contourList = contourPointer.getStructure();
double circleError = 0.50;
// check if contour is circle
while (contourList != null) {
if (contourList.elem_size >= 6) {
CvBox2D box = cvFitEllipse2(contourList);
CvSize size = new CvSize((int) (box.size.width * 0.5), (int) (box.size.width * 0.5));
double smallAxis, longAxis;
if (size.width < size.height) {
smallAxis = size.width;
longAxis = size.height;
} else {
smallAxis = size.height;
longAxis = size.width;
}
float circleMeasure = (float) ((longAxis - smallAxis) / longAxis);
if (circleMeasure < circleError) {
circleList.add((double) box.center.x);
circleList.add((double) box.center.y);
circleList.add((double) ((size.width + size.height) / 2));
}
}
contourList = contourList.h_next;
}
What is the expected output? What do you see instead?
Now when i debug it, as soon as i hit the line
CvBox2D box = cvFitEllipse2(contourList);
i get the error message:
"OpenCV Error: Incorrect size of input array (Number of points should be >= 6)
in unknown function, file ..\..\..\..\ocv\opencv\src\cv\cvshapedescr.cpp, line
972"
So i am wondering if im doing something fundamentaly wrong here? Maybe you have
an idea?
What version of the product are you using? On what operating system?
I'm using the 2010-07-30 release of javacv and OpenCV 2.1.0 with Eclipse Helios
on Windows XP.
Best Regards,
Chris
Original issue reported on code.google.com by [email protected]
on 10 Oct 2010 at 1:35
Hi Samuel,
thanks for your efforts with JavaCV.
Since me and a lot of other programmers are not very much familiar with
OpenCV, I would appreciate a few samples showing how e.g. the cvFindFace
function works.
Cheers,
Martin
Original issue reported on code.google.com by [email protected]
on 12 Mar 2010 at 11:24
What steps will reproduce the problem?
1. Compile and run the code
What is the expected output? What do you see instead?
This example should fully functional.
What version of the product are you using? On what operating system?
This example should work under all operating systems and all javaCV versions.
Please provide any additional information below.
It would be nice if anyone will extend the code or add a new functionality.
Original issue reported on code.google.com by [email protected]
on 21 Jan 2011 at 9:30
Attachments:
What steps will reproduce the problem?
1. Would like to use cvCornerFast(IGray, inFASTThreshhold, inNpixels,
inNonMaxSuppression, &numCorners, & corners) in javacv but the function is not
available?...
2. Can't find the function
What is the expected output? What do you see instead?
- No errors in eclipse, how ever there is compilation problems
What version of the product are you using? On what operating system?
- The latest javacv running on windows 7, 64 bit (not that it should make that
big of a difference)
Please provide any additional information below.
Thanks in advance!
Original issue reported on code.google.com by [email protected]
on 29 Oct 2010 at 7:36
public static void main(String[] args) {
IplImage image = cvLoadImage("c:\\teste.jpg");
if(image != null){
System.out.println("OK");
cvSmooth(image, image, CV_GAUSSIAN, 3, 0, 0, 0);
cvSaveImage("c:\\testecv.jpg", image);
}
}
What is the expected output? What do you see instead?
Save the cvImage
What version of the product are you using? On what operating system?
the last version on winxp
Please provide any additional information below.
#
# A fatal error has been detected by the Java Runtime Environment:
#
# EXCEPTION_ACCESS_VIOLATION (0xc0000005) at pc=0x035f13e0, pid=4060, tid=3536
#
# JRE version: 6.0_21-b06
# Java VM: Java HotSpot(TM) Client VM (17.0-b16 mixed mode, sharing windows-x86
)
# Problematic frame:
# C [libhighgui200.dll+0xd13e0]
Original issue reported on code.google.com by [email protected]
on 24 Aug 2010 at 6:02
Hi Samuel!!!
First of all you thank you for this interface. But i have problem with
cvContourArea. I use Opencv 2.1 and i use this method like this result =
Math.abs(cvContourArea( contour , CV_WHOLE_SEQ, 0)); . And i get this error
"OpenCV Error: Bad argument (Input array is not a valid matrix)".
The whole error part is
OpenCV Error: Bad argument (Input array is not a valid matrix)
in function , ..\..\..\src\cv\cvutils.cpp(53)
java.lang.Exception: Stack trace
at java.lang.Thread.dumpStack(Thread.java:1206)
at name.audet.samuel.javacv.JavaCvErrorCallback.callback(JavaCvErrorCallback.java:67)
at name.audet.samuel.javacv.jna.cv$v21.cvContourArea(Native Method)
at openCV.opencv.main(opencv.java:70)
How can i solve this problem?
Thanks in advance.
Regards,
Engin Öz
Original issue reported on code.google.com by [email protected]
on 15 Oct 2010 at 3:52
Attachments:
What steps will reproduce the problem?
1.Run cvAdaptiveThreshold on an image.
2.Set up the contour variables as demonstrated in the JavaCV example (with
contourPointer and contour).
3.Get the contours using cvFindContours with the same method demonstrated in
the main JavaCV example (on the front page).
4. Try getting the CvSeq variable from contourPointer using
PointerByReference():
CvSeq contours = contourPointer.getStructure();
What is the expected output? What do you see instead?
We expect to get a CvSeq containing all the contours found. Instead, there is a
stack overflow error, seemingly occuring due to repeated pointer to object
casts at the C/C++ level.
What version of the product are you using? On what operating system?
I am using Java 1.6, JDK 6, OpenCV 2.1.0, JNA 3.2.5, and JavaCV 20100730. This
is on the Windows XP OS.
Please provide any additional information below.
Converting to cvThreshold instead of cvAdaptiveThreshold (as in the example)
fixes the error. However, I am in need of adaptive thresholding for this
particular program.
Thank you for your work porting this to Java, it's immensely helpful.
Hopefully, you'll be able to help me figuring out this minor error.
- Nick
Original issue reported on code.google.com by [email protected]
on 7 Aug 2010 at 12:23
Eclipse shows an error when trying to use cvWarpPerspective with the
arguments (CvArr src, CvArr dst, CvMat map_matrix).
To be able to use this function, we have to use the following prototype:
cvWarpPerspective(CvArr src, CvArr dst, CvMat map_matrix,
int flags/*=CV_INTER_LINEAR+CV_WARP_FILL_OUTLIERS*/,
CvScalar.ByValue fillval/*=cvScalarAll(0)*/)
Original issue reported on code.google.com by [email protected]
on 9 May 2010 at 4:57
What steps will reproduce the problem?
1. Use a newer version of JNA instead of JNA 3.2.5
2. Create a histogram of an image
What is the expected output? What do you see instead?
Creating a histogram produces the following exception:
Exception in thread "main" java.lang.IllegalArgumentException:
Structure class name.audet.samuel.javacv.jna.cxcore$CvArr$ByReference
has unknown size (ensure all fields are public)
What version of the product are you using? On what operating system?
I was using the javacv 7/30/10 and jna 3.2.8 (latest version) on windows 7
professional
Please provide any additional information below.
Original issue reported on code.google.com by [email protected]
on 9 Oct 2010 at 6:13
Because I believe that examples are the easiest way how to use JavaCV, I am
sending a sample of running SIFT on images.
In the attached code I am sending en example how to use OpenCV surf to extract
features from an image.
What steps will reproduce the problem?
1. Compile and run the code
What is the expected output? What do you see instead?
Obtaining information about point of interest.
It would be nice to extend the code so we can:
1) Extract points of interest. The code in C is the following:
CvSeqReader img_reader = new CvSeqReader();
cvStartReadSeq( imageDescriptors, img_reader, 0 );
for (int i = 0; i < imageDescriptors.size(); i++) {
float descriptor = (float) img_reader.ptr;
CV_NEXT_SEQ_ELEM(img_reader.seq.elem_size, img_reader);
memcpy(img_ptr, descriptor,
length * com.sun.jna.Native.getNativeSize(Float.class));
img_ptr += length;
}
2) make the whole example functional as in find_obj.cpp
(https://code.ros.org/trac/opencv/browser/trunk/opencv/samples/c/find_obj.cpp?re
v=2270).
The code to be fixed is commented at the moment.
What version of the product are you using? On what operating system?
This should work under all the version and operating systems
Original issue reported on code.google.com by [email protected]
on 21 Jan 2011 at 9:21
Attachments:
Hi Samuel,
Is Flann in JavaCV? I was looking at cv and cvcore and didn't find them
Thanks!
Original issue reported on code.google.com by [email protected]
on 15 Oct 2010 at 6:53
What steps will reproduce the problem?
Just trying to run the code.
What is the expected output? What do you see instead?
I expect to a window streaming the video. But I get the following error :
java.lang.Exception: cvCreateFileCapture() Error: Could not create camera
capture.
at name.audet.samuel.javacv.OpenCVFrameGrabber.start(OpenCVFrameGrabber.java:93)
at mainPrg.main(mainPrg.java:22)
What version of the product are you using? On what operating system?
OpenCV 2.0 on Windows 7 Professinal
Please provide any additional information below.
I have recompiled the OpenCV source code without SSE and OpenMP instructions
(as suggested).
I'm attaching the code :
Original issue reported on code.google.com by [email protected]
on 3 Sep 2010 at 4:06
Attachments:
Hi, thanks for making this great port for opencv to java.
But, I have a critical problem that prevents me from using the interface.
The problem is that jni*.dll files need dll files whose names are in format
OPENCV_*.dll BUT my the dlls residing in my opencv/bin directory have names in
format libopencv_*.dll.
Even if this problem can be solved with renaming the dlls, I wanted to notify
you about this issue. Because by default opencv dlls come in the format
libopencv_*.dll and using them in that way seems more convenient.
Cheers
Behlül
Original issue reported on code.google.com by [email protected]
on 23 Feb 2011 at 4:45
I tried to create a simple sample using cv SURF feature but got the
following error. Could you take a look what I did wrong or provide a simple
example how to use cv SURF function? Thanks.
OpenCV Error: Assertion failed (CV_MAT_TYPE(img->type) == CV_8UC1) in
unknown function, file ..\..\..\..\ocv\opencv\src\cv\cvsurf.cpp, line 698
Here is the junit test I tried to run:
@Test
public void shouldRetrieveSURFPoint() throws Exception {
ObjectFinder finder = new ObjectFinder(cvLoadImage("lily.jpg"));
Settings setting = finder.getSettings();
assertNotNull(setting);
}
Original issue reported on code.google.com by [email protected]
on 25 May 2010 at 3:36
What steps will reproduce the problem?
1. compiled open cv 2.1 without sse,sse2, fast math and -o3 options, downloaded
latest jna and javacv and correctly set the library path with eclipse
2.downloaded test2.class with eclipse
3.runned
What is the expected output? What do you see instead?
[ 0.99636316, 0.042701807, -23.595554
-0.043815516, 0.99894774, -4.3367324
2.283744E-4, 5.2293086E-5, 0.9971857 ]
OpenCV Error: Bad argument (Invalid classifier cascade)
in function cvHaarDetectObjects,
C:\Users\etekno\Desktop\OpenCV-2.1.0\src\cv\cvhaar.cpp(1007)
java.lang.Exception: Stack trace
at java.lang.Thread.dumpStack(Unknown Source)
at com.googlecode.javacv.JavaCvErrorCallback.callback(JavaCvErrorCallback.java:67)
at com.googlecode.javacv.jna.cv.cvHaarDetectObjects(Native Method)
at com.googlecode.javacv.jna.cv.cvHaarDetectObjects(cv.java:2328)
at Test2.main(Test2.java:72)
What version of the product are you using? On what operating system?
i'm using eclipse galileo on windows7 Professional 64bit.
java version "1.6.0_20"
Java(TM) SE Runtime Environment (build 1.6.0_20-b02)
Java HotSpot(TM) 64-Bit Server VM (build 16.3-b01, mixed mode)
Please provide any additional information below.
Before i tried recompiling opencv 2.1 many times, i needed to remove the sse,
sse2 AND fastmath, -o3 options to not get blue screen crashes after trying to
stop the test2.class.
Now recompiled like that it does not crash all the system but still gives me
the error written above while it pops out a dialog telling me that c++ runtime
library has terminated in an unusual way.
While playing the test2.class the cam led correctly lights, it pops a frame on
the screen but i can't see the image because it's too small and then it
crashes. I tried with the built in cam on my laptop and a usb cam.
Do i need to remove some other options with cmake gui? it can be a 64bit
problem?
I managed to work with opencv and java with the processing + opencv.jar
libraries but it works only on version 1.0 that is SLOW and also less
functionalities. Then i finally found your project and i'd really like to use
it for my thesis :-/
Original issue reported on code.google.com by [email protected]
on 28 Dec 2010 at 1:25
What steps will reproduce the problem?
CvPOSITObject positObj;
double focalLength;
CvTermCriteria criteria;
float[] rotationMatrix = new float[9];
float[] translationVector = new float[3];
static final Point2f[] imagePoints = {new Point2f(-48, -224),
new Point2f(-287, -174),
new Point2f(132, -153),
new Point2f(-52, 149)};
static final Point3f[] points = {new Point3f(0, 0, 0),
new Point3f(0, 0, 10),
new Point3f(10, 0, 0),
new Point3f(0, 10, 0)};
criteria = new CvTermCriteria(
cxcore.CV_TERMCRIT_EPS | cxcore.CV_TERMCRIT_ITER, 100, 1.0e-4f);
CvPoint2D32f[] cvImagePoints = CvPoint2D32f.createArray(imagePoints.length);
for (int i = 0; i < cvImagePoints.length; i++)
{
double x = imagePoints[i].x;
double y = imagePoints[i].y;
// do nothing if any points are invalid.
cvImagePoints[i] = new CvPoint2D32f(x,y);
}
targetPoints = CvPoint3D32f.createArray(points.length);
for (int i = 0; i < points.length; i++)
{
targetPoints[i] = new CvPoint3D32f(points[i].x, points[i].y,
points[i].z);
}
positObj = CvPOSITObject.create(targetPoints);
cvPOSIT(positObj, cvImagePoints, focalLength, criteria.byValue(),
rotationMatrix,
translationVector);
What is the expected output? What do you see instead?
I expect valid rotation matrix and translation vector.
Instead all array entries are NaN.
The SAME code (essentially) in C++ works perfectly.
What version of the product are you using? On what operating system?
OpenCV 2.1, Latest, as far as I can tell, JavaCV
Please provide any additional information below.
I have tried various ways of creating the structures to use in the call to
cvPOSIT with no change in the result. I have since written a C++ version to
process my intended data with full success, but my whole application requires
Java, so I would like to know how to debug this or interpret how to properly
get the data into the call.
Original issue reported on code.google.com by [email protected]
on 15 Jan 2011 at 5:38
What steps will reproduce the problem?
1.i install OpenCV-2.2.0-win32-vs2010 in c:\openCV
2.Then i create a new project in the NETBEANS at windows XP platform
Then i add javaCV and JNA in the library of the projrct in the netbeans
3.Then i use the following code
import static com.googlecode.javacv.jna.cv.CV_BGR2GRAY;
import static com.googlecode.javacv.jna.cv.cvCvtColor;
import static com.googlecode.javacv.jna.cv.cvHaarDetectObjects;
import static com.googlecode.javacv.jna.cxcore.CV_AA;
import static com.googlecode.javacv.jna.cxcore.IPL_DEPTH_8U;
import static com.googlecode.javacv.jna.cxcore.cvGetSeqElem;
import static com.googlecode.javacv.jna.cxcore.cvLoad;
import static com.googlecode.javacv.jna.cxcore.cvPoint;
import static com.googlecode.javacv.jna.cxcore.cvRectangle;
import static com.googlecode.javacv.jna.highgui.cvLoadImage;
import static com.googlecode.javacv.jna.highgui.cvSaveImage;
import com.googlecode.javacv.JavaCvErrorCallback;
import com.googlecode.javacv.jna.cv.CvHaarClassifierCascade;
import com.googlecode.javacv.jna.cxcore.CvMemStorage;
import com.googlecode.javacv.jna.cxcore.CvPoint;
import com.googlecode.javacv.jna.cxcore.CvRect;
import com.googlecode.javacv.jna.cxcore.CvScalar;
import com.googlecode.javacv.jna.cxcore.CvSeq;
import com.googlecode.javacv.jna.cxcore.IplImage;
import java.io.IOException;
public class test {
// The cascade definition to be used for detection.
private static final String CASCADE_FILE = "haarcascade_frontalface_alt.xml";
public static void main(String arg[])throws Exception
{
// This will redirect the OpenCV errors to the Java console to give you
// feedback about any problems that may occur.
new JavaCvErrorCallback().redirectError();
// Load the original image.
IplImage originalImage= cvLoadImage("E:\\PhotoGallery\\Sceneries\\golf insignia.jpg",1);
// We need a grayscale image in order to do the recognition, so we
// create a new image of the same size as the original one.
IplImage grayImage = IplImage.create(originalImage.width, originalImage.height, IPL_DEPTH_8U, 1);
// We convert the original image to grayscale.
cvCvtColor(originalImage, grayImage, CV_BGR2GRAY);
CvMemStorage storage = CvMemStorage.create();
// We instantiate a classifier cascade to be used for detection, using the cascade definition.
CvHaarClassifierCascade cascade = new CvHaarClassifierCascade(cvLoad(CASCADE_FILE));
// We detect the faces.
CvSeq faces = cvHaarDetectObjects(grayImage, cascade, storage, 1.1, 1, 0);
//We iterate over the discovered faces and draw yellow rectangles around them.
for(int i = 0; i < faces.total; i++)
{
CvRect r =new CvRect(cvGetSeqElem(faces, i));
cvRectangle(originalImage, cvPoint(r.x, r.y), cvPoint(r.x + r.width, r.y + r.height), CvScalar.YELLOW, 1, CV_AA, 0);
}
// Save the image to a new file.
cvSaveImage("E:\\PhotoGallery", originalImage);
}
}
What is the expected output? What do you see instead?
i except the output images with rectangles at the faces , But u got the
following error
run:
Exception in thread "main" java.lang.UnsatisfiedLinkError: Unable to load
library 'cxcore': The specified module could not be found.
at com.sun.jna.NativeLibrary.loadLibrary(NativeLibrary.java:163)
at com.sun.jna.NativeLibrary.getInstance(NativeLibrary.java:236)
at com.sun.jna.NativeLibrary.getInstance(NativeLibrary.java:199)
at com.googlecode.javacv.jna.Loader.load(Loader.java:44)
at com.googlecode.javacv.jna.cxcore.<clinit>(cxcore.java:113)
at com.googlecode.javacv.JavaCvErrorCallback.redirectError(JavaCvErrorCallback.java:95)
at samplejavacv.test.main(test.java:43)
Java Result: 1
BUILD SUCCESSFUL (total time: 0 seconds)
What version of the product are you using? On what operating system?
I am using NETBEANS 6.9.1 in WINDOWS XP professional platform
But one doubt : may i need to build the openCV with cmake ? (here i didn't do
that)
Please provide any additional information below.
Original issue reported on code.google.com by [email protected]
on 29 Dec 2010 at 3:49
What steps will reproduce the problem?
1. attempting to port bgfg_seg.cpp to java
2. attempt to initialized with cvCreateGaussianBGModel using null for the
CvGaussBGStatModelParams and attempted with CvGaussBGStatModelParams with the
following parameters
params.win_size=2;
params.n_gauss=5;
params.bg_threshold=0.7;
params.std_threshold=3.5;
params.minArea=15;
params.weight_init=0.05;
params.variance_init=30;
What is the expected output? What do you see instead?
initialization
What version of the product are you using? On what operating system?
2.1 - fedora core 12
Please provide any additional information below.
Hello Everyone, and hello again Samuel
I have been tinkering with your fantastic jna interface with opencv for a
while.. Of course every issue I've encountered so far has always been with my
own source and this probably is not an exception, but I still have not figured
it out.
Any direction or info you might provide will be greatly appreciated.
Best Regards,
Greg.
Original issue reported on code.google.com by [email protected]
on 30 Jun 2010 at 7:28
Is there a way to implement something like this piece of code written in C++ to
Java?
IplImage* img=cvCreateImage(cvSize(640,480),IPL_DEPTH_8U,3);
((uchar *)(img->imageData + i*img->widthStep))[j*img->nChannels + 0]=111;
where i,j are image coordinates. Code found at:
http://www.cs.iit.edu/~agam/cs512/lect-notes/opencv-intro/index.html
Since this makes use of pointers, I was wondering if it is possible to do it in
Java. It may be a simple fix (I'm missing something) or it may not be possible
to do.
What I'm trying to do is access the colour channels of a particular pixel. I
have got it working with the cvGet2D method but the program got quite slow when
looping this method. Maybe using this new method will be faster (that is the
case in C++).
Thanks in advance
Original issue reported on code.google.com by [email protected]
on 27 Aug 2010 at 9:03
What steps will reproduce the problem?
1.Compile the java code.
2.Run the class file and specify the input image file, for example, java CvTest
cloud.jpg
3.The error message will display
What is the expected output? What do you see instead?
It is a fairly simple javacv code and the expected output is "Program
terminated normally". Instead I saw a fatal JVM error. The screenshot is
included in the attached file.
What version of the product are you using? On what operating system?
I am using OpenCV 2.1.0 and the latest version of javacv.
(javacv-bin-20101104.zip from the download page). The Java version I use is as
follows:
java version "1.6.0_22"
Java(TM) SE Runtime Environment (build 1.6.0_22-b04)
Java HotSpot(TM) Server VM (build 17.1-b03, mixed mode)
The operating system is Ubuntu 10.04 LTS
Please provide any additional information below.
1. I wrote a C++ version of the CvTest class. It works on my machine using
OpenCV.
2. Besides cvSmooth() method, cvFilter2D also crashed in the same environment.
3. The CvTest.java is the source file. I also included a sample image.
4. The search results I found on the Internet suggest some relation between
this error and the SSE instructions. But I found few details about how to fix
this problem.
Original issue reported on code.google.com by [email protected]
on 27 Nov 2010 at 4:38
Attachments:
What steps will reproduce the problem?
1. I open Eclipse, and I create a new project, as described here :
http://code.google.com/p/javacv/
2. In that new project, only one small class with a call to a opencv function
(I used the first sample code)
What is the expected output? What do you see instead?
I have the following error :
Exception in thread "main" java.lang.UnsatisfiedLinkError: Unable to load
library 'cxcore': dlopen(libcxcore.dylib, 9): image not found
What version of the product are you using? On what operating system?
I am on Mac Os X 1.5 (macbook). I downloaded the latest version of Javacv, and
used the SVN of OpenCV to compile.
Please provide any additional information below.
I installed OpenCV (with cmake), and I can compile and run the examples
included. So that works.
I compiled it without SSE support, and with the correct architecture (i386).
The library was installed in /usr/local/lib/libopencv_...
Maybe I did something wrong, but I really followed the documentation, and I end
up with that, so maybe it is really the documentation that has a problem.
Original issue reported on code.google.com by [email protected]
on 13 Sep 2010 at 11:33
What steps will reproduce the problem?
1. Executed the "Test2" example provided in the "Project Home" page
2. Executed a variance of the same (file attached "DetectFace.java"
What is the expected output? What do you see instead?
The expected output is to draw a rectagle around the detected objects, but
throws a runtime exception while calling cvCvtColor() method.
What version of the product are you using? On what operating system?
1. OpenCV 2.0
2. JDK 1.6
3. javacv downloded from this site
4. Java Native Access 3.2.5
5. Tried in Windows XP Professional and Windows 7 Ultimate
Please provide any additional information below.
* attached the java source code "DetectFace.java" with debug statements
* attached the log file created with the exception "hs_err_pid384.log"
Appreciate your valuable guidance on this.
Thanks in advance.
Regards,
Mohammed Sadiq
Original issue reported on code.google.com by [email protected]
on 7 Aug 2010 at 3:09
Attachments:
Hi Samuel,
before all, thanks for the great job did with wrapper :)
I'm trying to implement a simple motion-detection algorithm (and maybe, when
it's work, i can upload it into the samples code), but I've encountered a weird
problem.
My algorithm works in this manner:
1) Take current frame and the previous one, in this way:
while (canvasFrame.isVisible() && (frame = grabber.grab()) != null) {
cvSmooth(frame, frame, CV_GAUSSIAN, 9, 9, 2, 2);
if(image == null) {
image = IplImage.create(frame.width, frame.height, IPL_DEPTH_8U, 1);
cvCvtColor(frame, image, CV_RGB2GRAY);
}
else {
prevImage = IplImage.create(frame.width, frame.height, IPL_DEPTH_8U, 1);
prevImage = image;
image = IplImage.create(frame.width, frame.height, IPL_DEPTH_8U, 1);
cvCvtColor(frame, image, CV_RGB2GRAY);
}
if(diff == null)
diff = IplImage.create(frame.width, frame.height, IPL_DEPTH_8U, 1);
2) then if the two images was acquired correctly, I do the difference and
threshold it:
if(prevImage != null) {
cvAbsDiff(image, prevImage, diff);
cvThreshold(diff, diff, 64, 255, CV_THRESH_BINARY);
}
This works fine, but when I close the java-application and I rerun it, this
error appears: Buffers have not been created, and it appears continuosly for a
couple of attempts then it works again.
May it be related to the SSE compiled stuff?
Any help will be greatly appreciated :)
What steps will reproduce the problem?
1. Simply compiling and running the program
What is the expected output? What do you see instead?
Working code, I've got instead an error
What version of the product are you using? On what operating system?
Netbeans 6.8 under Ubuntu 10.04 (amd64 architecture), and OpenCV 2.1
Original issue reported on code.google.com by [email protected]
on 30 Sep 2010 at 10:40
What steps will reproduce the problem?
1. When I run Test2 example.
2. I have this message: "cvRetrieveFrame() Error: Could not retrieve frame."
3. It's the OpenCVFrameGraber class.
What version of the product are you using? On what operating system?
I installed all items described in the JavaCV web page.
I have MacOX 10.6.4.
OpenCV: I have the latest official version of OpenCV installed on the root. The
samples (samples/c) provided by OpenCV are working well, particularly the face
detection.
Please provide any additional information below.
For Test2: The webcam turned on when I run the program. The Canvas Frame
entitled "Some title" appear on the screen, before I got the message error.
ps: thanks for the good job, I would like to use JavaCV in my work, but I am
still afraid of getting such kind of errors. Do you have any idea from where
comes the problem? Thanks.
Original issue reported on code.google.com by [email protected]
on 24 Sep 2010 at 8:38
What steps will reproduce the problem?
1. When I make repeated calls to cvHaarDetectObjects(), it will eventually
crash.
What is the expected output? What do you see instead?
I expect it to return a CvSeq object, but instead it will crash.
What version of the product are you using? On what operating system?
I am using the latest version of the product, and I have tried it on both
Windows and MacOS X.
While the actual output of the error on each machine is slightly different, the
problem is in the
same location.
Please provide any additional information below.
I have attached the code that I am using (FindFaces.java), which is rather
straightforward. Also, I
have included the error logs that were produced on the Windows machine as well
as a mediocre
one I generated from the Mac OS X machine. They are the same physical machine.
This may be related strictly to JNI, but I wanted to post here before I went
there.
Original issue reported on code.google.com by [email protected]
on 18 May 2010 at 10:50
Attachments:
What steps will reproduce the problem?
1.
2.
3.
What is the expected output? What do you see instead?
What version of the product are you using? On what operating system?
Please provide any additional information below.
Original issue reported on code.google.com by [email protected]
on 29 Dec 2010 at 3:42
What steps will reproduce the problem?
1. Create new project in Eclipse for example
2. Paste the sample code Test2
3. Run
If I compile OpenCV in 32 bits
- compiling the c examples works, and they work properly
- your code example fails with the output :
Exception in thread "main" java.lang.UnsatisfiedLinkError: Unable to load
library 'cxcore': dlopen(/usr/local/lib/libcxcore.dylib, 9): no suitable image
found. Did find:
/usr/local/lib/libcxcore.dylib: mach-o, but wrong architecture
/usr/local/lib/libcxcore.dylib: mach-o, but wrong architecture
at com.sun.jna.NativeLibrary.loadLibrary(NativeLibrary.java:163)
at com.sun.jna.NativeLibrary.getInstance(NativeLibrary.java:236)
at com.sun.jna.NativeLibrary.getInstance(NativeLibrary.java:199)
at name.audet.samuel.javacv.jna.Loader.load(Loader.java:44)
at name.audet.samuel.javacv.jna.cxcore.<clinit>(cxcore.java:115)
at name.audet.samuel.javacv.JavaCvErrorCallback.redirectError(JavaCvErrorCallback.java:95)
at com.Test.main(Test.java:14)
If I compile OpenCV in 64 bits
- compiling the c examples fails with the output :
compiling camshiftdemo.c
ld warning: in /usr/local/lib/libml.dylib, file is not of required architecture
ld warning: in /usr/local/lib/libcvaux.dylib, file is not of required
architecture
- compiling your code example fails with the output :
Exception in thread "main" java.lang.Exception: cvRetrieveFrame() Error: Could
not retrieve frame.
at name.audet.samuel.javacv.OpenCVFrameGrabber.grab(OpenCVFrameGrabber.java:149)
at com.Test.main(Test.java:33)
What version of the product are you using? On what operating system?
Mac Os X 1.5, on Macbook bought in 2009 (so 64 bits)
Original issue reported on code.google.com by [email protected]
on 14 Sep 2010 at 3:40
would be nice if IplImage could accept arrays and/or Buffers instead of
BufferedImage
Original issue reported on code.google.com by [email protected]
on 20 Oct 2010 at 7:18
Hi,
is it possible to do face recognition using javacv?
i mean not face detection but i want to search for a person in a group of
images meaning i will input a picture and search for the person in other
pictures....
can this be done using javacv?
can we get more samples if this is possible and is there a documenation for the
functions that can be done using javacv....
thank you very much
Original issue reported on code.google.com by [email protected]
on 30 Jul 2010 at 7:12
Does JavaCV have a machine learning algorithm like OpenCV??
If so, can you post some samples??
I need it for my image classification alogrihtm. Thanks:D
Original issue reported on code.google.com by [email protected]
on 11 Jul 2010 at 10:24
What steps will reproduce the problem?
1.I open Eclipse, and I create a new project.
2. I add javacv-src-20100730.zip, javacv-bin-20100730.zip, and jna.jar to my
project. I have copy this files in OpenCV2.1>lib
2.I write a simple code that you put in the example.
What is the expected output? What do you see instead?
I run but it has errors. "the import name cannot be resolved". I had written
this 'import static name.audet.samuel.javacv.jna.cxcore.*;'.
What version of the product are you using? On what operating system?
I use Eclipse for java and OpenCV2.1. I dont' know what the problem is, can you
help me, please?
Please provide any additional information below.
Original issue reported on code.google.com by [email protected]
on 26 Oct 2010 at 6:59
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.