After Width: | Height: | Size: 23 KiB |
After Width: | Height: | Size: 15 KiB |
After Width: | Height: | Size: 42 KiB |
After Width: | Height: | Size: 12 KiB |
After Width: | Height: | Size: 70 KiB |
After Width: | Height: | Size: 42 KiB |
After Width: | Height: | Size: 25 KiB |
After Width: | Height: | Size: 25 KiB |
After Width: | Height: | Size: 32 KiB |
After Width: | Height: | Size: 14 KiB |
After Width: | Height: | Size: 34 KiB |
After Width: | Height: | Size: 38 KiB |
After Width: | Height: | Size: 25 KiB |
Before Width: | Height: | Size: 768 KiB |
After Width: | Height: | Size: 606 KiB |
@ -0,0 +1,49 @@ |
||||
<project name="SimpleSample" basedir="." default="rebuild-run"> |
||||
|
||||
<property name="src.dir" value="src"/> |
||||
|
||||
<property name="lib.dir" value="${ocvJarDir}"/> |
||||
<path id="classpath"> |
||||
<fileset dir="${lib.dir}" includes="**/*.jar"/> |
||||
</path> |
||||
|
||||
<property name="build.dir" value="build"/> |
||||
<property name="classes.dir" value="${build.dir}/classes"/> |
||||
<property name="jar.dir" value="${build.dir}/jar"/> |
||||
|
||||
<property name="main-class" value="${ant.project.name}"/> |
||||
|
||||
|
||||
<target name="clean"> |
||||
<delete dir="${build.dir}"/> |
||||
</target> |
||||
|
||||
<target name="compile"> |
||||
<mkdir dir="${classes.dir}"/> |
||||
<javac srcdir="${src.dir}" destdir="${classes.dir}" classpathref="classpath"/> |
||||
</target> |
||||
|
||||
<target name="jar" depends="compile"> |
||||
<mkdir dir="${jar.dir}"/> |
||||
<jar destfile="${jar.dir}/${ant.project.name}.jar" basedir="${classes.dir}"> |
||||
<manifest> |
||||
<attribute name="Main-Class" value="${main-class}"/> |
||||
</manifest> |
||||
</jar> |
||||
</target> |
||||
|
||||
<target name="run" depends="jar"> |
||||
<java fork="true" classname="${main-class}"> |
||||
<sysproperty key="java.library.path" path="${ocvLibDir}"/> |
||||
<classpath> |
||||
<path refid="classpath"/> |
||||
<path location="${jar.dir}/${ant.project.name}.jar"/> |
||||
</classpath> |
||||
</java> |
||||
</target> |
||||
|
||||
<target name="rebuild" depends="clean,jar"/> |
||||
|
||||
<target name="rebuild-run" depends="clean,run"/> |
||||
|
||||
</project> |
@ -0,0 +1,19 @@ |
||||
import org.opencv.core.Mat; |
||||
import org.opencv.core.CvType; |
||||
import org.opencv.core.Scalar; |
||||
|
||||
class SimpleSample { |
||||
|
||||
static{ System.loadLibrary("opencv_java244"); } |
||||
|
||||
public static void main(String[] args) { |
||||
Mat m = new Mat(5, 10, CvType.CV_8UC1, new Scalar(0)); |
||||
System.out.println("OpenCV Mat: " + m); |
||||
Mat mr1 = m.row(1); |
||||
mr1.setTo(new Scalar(1)); |
||||
Mat mc5 = m.col(5); |
||||
mc5.setTo(new Scalar(5)); |
||||
System.out.println("OpenCV Mat data:\n" + m.dump()); |
||||
} |
||||
|
||||
} |
@ -0,0 +1,7 @@ |
||||
<?xml version="1.0" encoding="UTF-8"?> |
||||
<classpath> |
||||
<classpathentry kind="src" path="src"/> |
||||
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.7"/> |
||||
<classpathentry kind="con" path="org.eclipse.jdt.USER_LIBRARY/opencv-2.4.4"/> |
||||
<classpathentry kind="output" path="bin"/> |
||||
</classpath> |
@ -0,0 +1,17 @@ |
||||
<?xml version="1.0" encoding="UTF-8"?> |
||||
<projectDescription> |
||||
<name>HelloCV</name> |
||||
<comment></comment> |
||||
<projects> |
||||
</projects> |
||||
<buildSpec> |
||||
<buildCommand> |
||||
<name>org.eclipse.jdt.core.javabuilder</name> |
||||
<arguments> |
||||
</arguments> |
||||
</buildCommand> |
||||
</buildSpec> |
||||
<natures> |
||||
<nature>org.eclipse.jdt.core.javanature</nature> |
||||
</natures> |
||||
</projectDescription> |
@ -0,0 +1,11 @@ |
||||
eclipse.preferences.version=1 |
||||
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled |
||||
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.7 |
||||
org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve |
||||
org.eclipse.jdt.core.compiler.compliance=1.7 |
||||
org.eclipse.jdt.core.compiler.debug.lineNumber=generate |
||||
org.eclipse.jdt.core.compiler.debug.localVariable=generate |
||||
org.eclipse.jdt.core.compiler.debug.sourceFile=generate |
||||
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error |
||||
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error |
||||
org.eclipse.jdt.core.compiler.source=1.7 |
@ -0,0 +1,12 @@ |
||||
import org.opencv.core.CvType; |
||||
import org.opencv.core.Mat; |
||||
|
||||
public class Main { |
||||
|
||||
public static void main(String[] args) { |
||||
System.loadLibrary("opencv_java244"); |
||||
Mat m = Mat.eye(3, 3, CvType.CV_8UC1); |
||||
System.out.println("m = " + m.dump()); |
||||
} |
||||
|
||||
} |
@ -1,2 +1 @@ |
||||
addSbtPlugin("com.typesafe.sbteclipse" % "sbteclipse-plugin" % "2.1.0") |
||||
|
@ -0,0 +1,44 @@ |
||||
import org.opencv.core.Core; |
||||
import org.opencv.core.Mat; |
||||
import org.opencv.core.MatOfRect; |
||||
import org.opencv.core.Point; |
||||
import org.opencv.core.Rect; |
||||
import org.opencv.core.Scalar; |
||||
import org.opencv.highgui.Highgui; |
||||
import org.opencv.objdetect.CascadeClassifier; |
||||
|
||||
/* |
||||
* Detects faces in an image, draws boxes around them, and writes the results |
||||
* to "faceDetection.png". |
||||
*/ |
||||
public class DetectFaceDemo { |
||||
public void run() { |
||||
System.out.println("\nRunning DetectFaceDemo"); |
||||
|
||||
// Create a face detector from the cascade file in the resources
|
||||
// directory.
|
||||
CascadeClassifier faceDetector = new CascadeClassifier(getClass() |
||||
.getResource("/lbpcascade_frontalface.xml").getPath()); |
||||
Mat image = Highgui.imread(getClass().getResource( |
||||
"/AverageMaleFace.jpg").getPath()); |
||||
|
||||
// Detect faces in the image.
|
||||
// MatOfRect is a special container class for Rect.
|
||||
MatOfRect faceDetections = new MatOfRect(); |
||||
faceDetector.detectMultiScale(image, faceDetections); |
||||
|
||||
System.out.println(String.format("Detected %s faces", |
||||
faceDetections.toArray().length)); |
||||
|
||||
// Draw a bounding box around each face.
|
||||
for (Rect rect : faceDetections.toArray()) { |
||||
Core.rectangle(image, new Point(rect.x, rect.y), new Point(rect.x |
||||
+ rect.width, rect.y + rect.height), new Scalar(0, 255, 0)); |
||||
} |
||||
|
||||
// Save the visualized detection.
|
||||
String filename = "faceDetection.png"; |
||||
System.out.println(String.format("Writing %s", filename)); |
||||
Highgui.imwrite(filename, image); |
||||
} |
||||
} |
Before Width: | Height: | Size: 15 KiB After Width: | Height: | Size: 15 KiB |
Before Width: | Height: | Size: 1.5 MiB After Width: | Height: | Size: 1.5 MiB |
Before Width: | Height: | Size: 1.5 MiB After Width: | Height: | Size: 1.5 MiB |
@ -1,44 +0,0 @@ |
||||
import org.opencv.core.Core; |
||||
import org.opencv.core.Mat; |
||||
import org.opencv.core.MatOfRect; |
||||
import org.opencv.core.Point; |
||||
import org.opencv.core.Rect; |
||||
import org.opencv.core.Scalar; |
||||
import org.opencv.highgui.Highgui; |
||||
import org.opencv.objdetect.CascadeClassifier; |
||||
|
||||
/* |
||||
* Detects faces in an image, draws boxes around them, and writes the results |
||||
* to "faceDetection.png". |
||||
*/ |
||||
public class DetectFaceDemo { |
||||
public void run() { |
||||
System.out.println("\nRunning DetectFaceDemo"); |
||||
|
||||
// Create a face detector from the cascade file in the resources
|
||||
// directory.
|
||||
CascadeClassifier faceDetector = new CascadeClassifier(getClass() |
||||
.getResource("/lbpcascade_frontalface.xml").getPath()); |
||||
Mat image = Highgui.imread(getClass().getResource( |
||||
"/AverageMaleFace.jpg").getPath()); |
||||
|
||||
// Detect faces in the image.
|
||||
// MatOfRect is a special container class for Rect.
|
||||
MatOfRect faceDetections = new MatOfRect(); |
||||
faceDetector.detectMultiScale(image, faceDetections); |
||||
|
||||
System.out.println(String.format("Detected %s faces", |
||||
faceDetections.toArray().length)); |
||||
|
||||
// Draw a bounding box around each face.
|
||||
for (Rect rect : faceDetections.toArray()) { |
||||
Core.rectangle(image, new Point(rect.x, rect.y), new Point(rect.x |
||||
+ rect.width, rect.y + rect.height), new Scalar(0, 255, 0)); |
||||
} |
||||
|
||||
// Save the visualized detection.
|
||||
String filename = "faceDetection.png"; |
||||
System.out.println(String.format("Writing %s", filename)); |
||||
Highgui.imwrite(filename, image); |
||||
} |
||||
} |