1.11M Members

Color Detection Using OpenCV

 
0
 

how can i detect color using OpenCV i've tried thiscode

Code blocks are created by indenting at least 4 spaces
... and can span multiple lines





    import static com.googlecode.javacv.cpp.opencv_core.*;
import static com.googlecode.javacv.cpp.opencv_highgui.*;
import static com.googlecode.javacv.cpp.opencv_imgproc.*;
//non-static imports
import com.googlecode.javacv.cpp.opencv_core.CvScalar;
import com.googlecode.javacv.cpp.opencv_core.IplImage;

public class ColorDetect {
    //color range of red like color
    static CvScalar min = cvScalar(0, 0, 130, 0);
    static CvScalar max= cvScalar(140, 110, 255, 0);

    public static void main(String[] args) {
        //read image
        IplImage orgImg = cvLoadImage("C:\\image.jpg");
        //create binary image of original size
        IplImage imgThreshold = cvCreateImage(cvGetSize(orgImg), 8, 1);
        //apply thresholding
        cvInRangeS(orgImg, min, max, imgThreshold);
        //smooth filter- median
        cvSmooth(imgThreshold, imgThreshold, CV_MEDIAN, 13);
        //save
        cvSaveImage("C:\\threshold.jpg", imgThreshold);
    }
}

but i got the following error:
*
java.lang.UnsatisfiedLinkError: C:\Documents and Settings\suresh\Local Settings\Temp\jniopencv_core8513592286291741084.dll: Can't find dependent libraries
at java.lang.ClassLoader$NativeLibrary.load(Native Method)
at java.lang.ClassLoader.loadLibrary0(ClassLoader.java:1758)
at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1654)
at java.lang.Runtime.load0(Runtime.java:770)
at java.lang.System.load(System.java:1003)
at com.googlecode.javacpp.Loader.load(Loader.java:361)
at com.googlecode.javacpp.Loader.load(Loader.java:294)
at com.googlecode.javacv.cpp.opencv_core.<clinit>(opencv_core.java:129)
at ColorDetect.<clinit>(ColorDetect.java:19)
Could not find the main class: ColorDetect. Program will exit.
Exception in thread "main" Java Result: 1
BUILD SUCCESSFUL (total time: 0 seconds)*

What can i do please Help.

You
Post:
Start New Discussion
Tags Related to this Article