⑴ opencv求摄像机参数中函数调用错误求解
整个项目的结构图:
编写DetectFaceDemo.java,代码如下:
[java] view
plainprint?
package com.njupt.zhb.test;
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");
System.out.println(getClass().getResource("lbpcascade_frontalface.xml").getPath());
// 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("lena.png").getPath());
//注意:源程序的路径会多打印一个‘/’,因此总是出现如下错误
/*
* Detected 0 faces Writing faceDetection.png libpng warning: Image
* width is zero in IHDR libpng warning: Image height is zero in IHDR
* libpng error: Invalid IHDR data
*/
//因此,我们将第一个字符去掉
String xmlfilePath=getClass().getResource("lbpcascade_frontalface.xml").getPath().substring(1);
CascadeClassifier faceDetector = new CascadeClassifier(xmlfilePath);
Mat image = Highgui.imread(getClass().getResource("we.jpg").getPath().substring(1));
// 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);
}
}
package com.njupt.zhb.test;
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");
System.out.println(getClass().getResource("lbpcascade_frontalface.xml").getPath());
// 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("lena.png").getPath());
//注意:源程序的路径会多打印一个‘/’,因此总是出现如下错误
/*
* Detected 0 faces Writing faceDetection.png libpng warning: Image
* width is zero in IHDR libpng warning: Image height is zero in IHDR
* libpng error: Invalid IHDR data
*/
//因此,我们将第一个字符去掉
String xmlfilePath=getClass().getResource("lbpcascade_frontalface.xml").getPath().substring(1);
CascadeClassifier faceDetector = new CascadeClassifier(xmlfilePath);
Mat image = Highgui.imread(getClass().getResource("we.jpg").getPath().substring(1));
// 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);
}
}
3.编写测试类:
[java] view
plainprint?
package com.njupt.zhb.test;
public class TestMain {
public static void main(String[] args) {
System.out.println("Hello, OpenCV");
// Load the native library.
System.loadLibrary("opencv_java246");
new DetectFaceDemo().run();
}
}
//运行结果:
//Hello, OpenCV
//
//Running DetectFaceDemo
///E:/eclipse_Jee/workspace/JavaOpenCV246/bin/com/njupt/zhb/test/lbpcascade_frontalface.xml
//Detected 8 faces
//Writing faceDetection.png
package com.njupt.zhb.test;
public class TestMain {
public static void main(String[] args) {
System.out.println("Hello, OpenCV");
// Load the native library.
System.loadLibrary("opencv_java246");
new DetectFaceDemo().run();
}
}
//运行结果:
//Hello, OpenCV
//
//Running DetectFaceDemo
///E:/eclipse_Jee/workspace/JavaOpenCV246/bin/com/njupt/zhb/test/lbpcascade_frontalface.xml
//Detected 8 faces
//Writing faceDetection.png
⑵ tensor 与 vector 有什么区别
张量积(tensor proct) ,可以应用于不同的上下文中如向量、矩阵、张量、向量空间、代数、拓扑向量空间和模。在各种情况下这个符号的意义是同样的: 最一般的双线性运算。在某些上下文中也叫做外积。tensor是矩阵分析里面的张量,表示高维数组,或者叫多路数据。二阶张量就是矩阵,一阶张量就是向量。高阶SVD相对于矩阵SVD更能提取出高维数据的内在结构。
Vector 类在 java 中可以实现自动增长的对象数组; vector在C++标准模板库中的部分内容,它是一个多功能的,能够操作多种数据结构和算法的模板类和函数库。
(1) 矢量:具有方向性的量。
(2) 编程语言方面:vector是C++标准模板库中的部分内容,中文偶尔译作“容器”,但并不准确。它是一个多功能的,能够操作多种数据结构和算法的模板类和函数库。vector之所以被认为是一个容器,是因为它能够像容器一样存放各种类型的对象,简单地说,vector是一个能够存放任意类型的动态数组,能够增加和压缩数据。
⑶ 如何将SVD算法用maprece实现
数据挖掘比赛算法
examples/src/main/java/org/apache/mahout/cf/taste/example/kddcup/track1/svd
推荐系统中利用SVD实现降维
core/src/main/java/org/apache/mahout/cf/taste/impl/recommender/svd
⑷ java 一个字符串12345678,怎样每隔2个数字,用#连接起来
StringgetStr(Stringstr){
if(str.length()<=2){
returnstr;
}
returnstr.substring(0,2)+"#"+getStr(str.substring(2));
}
不要太简单
⑸ 为什么java中输入char要移取缓冲区中的回车符
为什么回车会被储存在缓冲区中啊。既然回车是结束符,第一个gets 不能接收因为gets()函数默认的是以回车结尾,不然你怎么知道输到什么时候算完啊,,phlsVd
⑹ svd 计算矩阵 java
这个直接算。
第一行乘以第一列写在结果的第一行第一列的那个项,然后第一行乘以第二列写在对应的地方。
先解前2个,然后在和第三个求。-1的公式记得不。
2行2列的-1结果。就是分之一。
BOB是个转至有T。
5*(-0.4472)+5*(-0.3586).......
然后第二列也是这样的。
-0.3775可以算出来
第二个0.0802算不出来。
第一个答案是-0.3775.第二个是0.1350
过程如下:
(1):[-5*(0.4472+0.3586+0.5316) 5*(0.5373-0.2461-0.1187)]
按矩阵形式写好,后面的乘法照写。
(2):后面的倒数过来。写分之一,然后就答案了
希望可以帮助到你,^_~
⑺ Java字符串替换的问题
可以做成静态函数;可以用正则表达式替换。
⑻ 一个rcp插件,在普通测试类以java application程序运行时正确。当以eclipse application运行时,界面调用
你在开发环境时用java app跑,程序运行在开发环境的eclipse
用eclipse app跑,程序运行在runtime环境里
检查runtime设置里面的依赖关系吧
⑼ 特种部队阻神是谁
二等兵-JAVA 好久没上 特种部队了,
曾经的FR-F2使的出神入化,人称 狙神!
二等兵家族里的头号王牌,后因为工作原因从特种部队退役。
退役前,曾该名为:“谁都不认识了”
该号:目前军衔:绿色中校
使用者多为他曾经的战友。
二等兵-JAVA 曾经的狙神! 退役兵!
⑽ opencv中把矩阵进行奇异值分解后怎样重构矩阵
SVD相当于:
C为mxn阶矩阵,U为mxm阶酉矩阵,E为mxn阶实数对角矩阵,V为nxn阶酉矩阵。
E矩阵对角线上的元素等于C的奇异值。
在OpenCV中可以用
solve(InputArraysrc1, InputArraysrc2, OutputArraydst, intflags=DECOMP_SVD)
你是不是要用SVD求解最小二乘问题?
线性方程组Cx=b,求其最小二乘解。
你可以先求出C的伪逆C+。
C+=V(E+)(UT)
(E+)是E的伪逆,将E主对角线上每个非零元素都求倒数之后再转置得到.
(UT)是U的转置。
最后计算出最小二乘解为:(C+)b