我在java中使用opencv 2.4.10检测到图像中的面部
我把我的面部检测代码.
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.core.Size;
import org.opencv.highgui.Highgui;
import org.opencv.imgproc.Imgproc;
import org.opencv.objdetect.CascadeClassifier;
public class FaceDetector {
public static void main(String[] args)throws Exception {
int x,y,height,width;
System.loadLibrary(Core.NATIVE_LIBRARY_NAME);
System.out.println("\nRunning FaceDetector");
//CascadeClassifier faceDetector = new CascadeClassifier(FaceDetector.class.getResource("haarcascade_frontalface_alt.xml").getPath());
CascadeClassifier faceDetector=new CascadeClassifier();
faceDetector.load("C:/opencv-2.4.10/opencv/sources/data/haarcascades/haarcascade_frontalface_alt.xml");
//System.out.println(""+faceDetector);
// Mat image = Highgui .imread(FaceDetector.class.getResource("D:/shekar.jpg").getPath());
Mat image = Highgui .imread("D:/Eclipse - New Juno/New Juno Projects/detectface/man1.jpg");
MatOfRect faceDetections = new MatOfRect();
faceDetector.detectMultiScale(image, faceDetections);
System.out.println(String.format("Detected %s faces", faceDetections.toArray().length));
for (Rect rect : …Run Code Online (Sandbox Code Playgroud) var foo = {unique_prop: 1}, bar = {unique_prop: 2}, object = {};
object[foo] = 'anu';
console.log(object[bar]);
Run Code Online (Sandbox Code Playgroud)
上面的代码输出"anu".
toString 方法将非字符串对象强制转换为字符串对象.
在上面的代码中object[bar]输出值为'anu'.
文件说'因为foo和bar都转换为相同的字符串'
我无法理解toString此代码中的java脚本方法.
任何人都可以解释它是如何工作的?