画像からスキューレベルを検出したい。私は次のコードを持っています:
public void analyse(CvMat img) {
rows = img.rows();
cols = img.cols();
// create edge-map from rois
CvMat edgeMap = cvCreateMat(rows, cols, CV_8UC1);
cvCanny(img, edgeMap, 100, 400, 3);
// transform to hough
CvMemStorage storage = cvCreateMemStorage(0);
lines = cvHoughLines2(edgeMap, storage, CV_HOUGH_PROBABILISTIC, 1,
EuclideanDistance euclideanDistance = new EuclideanDistance();
double maxDistance = Double.MIN_VALUE;
for (int i = 0; i < lines.total(); ++i) {
Pointer line = cvGetSeqElem(lines, i);
CvPoint pt1 = new CvPoint(line).position(0);
CvPoint pt2 = new CvPoint(line).position(1);
double distance = euclideanDistance.getDistance(pt1, pt2);
double currentAngle = Math.atan2(pt2.y() - pt1.y(),
pt2.x() - pt1.x())
* 180 / Math.PI;
System.out.println(currentAngle);
if (distance > maxDistance) {
skewAngle = currentAngle;
}
}
私のテスト画像は
スキュー レベルは -16 度だと思いますが、私のコードによると、それは 25 度です...
for も平均角度を 25 で出力します。私のハフパラメータが間違っていますか?
//EDIT ここは houghLines からの描画です
挨拶