① 用opencv的程序做攝像機標定,需要輸入什麼參數
需要輸入標定板得大小信息,也就是你的方格的大小,還有就是標定板得長和寬,還有就是標定的圖片的數量。int n_board=9;
int n_board_1=9;
int sn_board=0;
int sn_board_1=0;
int board_w=9;
int board_h=6;
int board_n=board_w*board_h;
② 之前您的那個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
③ openCV攝像機標定
外參數中的R就是旋轉矩陣,t就是平移向量。
④ 如何利用opencv計算圖像畸變系數,並進行校正與攝像機標定
如果知道圖像,不知道相機還怎麼通過相機來標定畸變。
1:只給定一張圖片回可以根據圖像中相關特答征進行標定,簡單講就是利用: line is straight 這個原理。
2:目前最常用的方法,是通過二維標定板,通過對 reprojection error 最小化進行非線性優化,來實現對相機的標定。並非根據看似高大上的訓練集來標定。
3:畸變參數只是標定法所求參數的一部分,即:兩個徑向畸變系數和兩個切向畸變系數。消除畸變的目的是讓相機盡量地逼近針孔相機模型,這樣相機成像時直線才會保持其直線性。
4:一般常見的畸變校正演算法都是根據這一原理來實現的。當然,還有二般的情況。
⑤ opencv中使用的標定函數是什麼演算法
張正友的
A Flexible New Technique for Camera
Calibration
模型專是屬
A Generic Camera Model and Calibration Method for Conventional,
Wide-Angle, and Fish-Eye Lenses
⑥ opencv里的標定精度怎麼樣
我是來要測平面上的激源光光斑的中心位置,可以不用考慮Z坐標了。目前僅利用透視變換,標定後的絕對誤差大概十幾二十個微米,可是我要測的是3個微米或者4個微米的樣子,感覺這沒法測啊,誤差都大於要測量的長度。標定好後粗略算了下,圖像上相差一個像素的距離換算到實際距離也都有10來微米。。
⑦ 用opencv進行攝像頭的標定時,怎麼求取基線距離,焦距f,dx,dy,均已知!
stereocalib後 輸出的結果中 T 中的第一個數值 即為基線距離 即Tx
⑧ 有用過opencv的師兄么,現在導師讓我用opencv+機械手搞工件分揀,opencv我才剛接觸,對於我要實現的功能
這個說實話我是真的不知道
⑨ opencv標定程序相關
有路徑後用cvLoadImage讀。
Image<uchar> view(filename);這句就是讀入圖片?沒見過。