#pragma mark - -检测矩阵运算
- (void)check_Mat {
/*
double L11 = 42.5;
double L12 = 40.5;
double h11 = 1.3;
double h12 = h11 / 2;
NSMutableArray *realGoArray = [[NSMutableArray array] init];
for (int i = 0; i < 4; i++) {
MyPoint *tempPoint = [[MyPoint alloc] init];
if (i == 0) {
tempPoint.pointX = -h12;
tempPoint.pointY = -h12;
}
if (i == 1) {
tempPoint.pointX = L11 + h12;
tempPoint.pointY = -h12;
}
if (i == 2) {
tempPoint.pointX = L11 + h12;
tempPoint.pointY = L12 + h12;
}
if (i == 3) {
tempPoint.pointX = -h12;
tempPoint.pointY = h12 + h12;
}
[realGoArray addObject:tempPoint];
}
XPFLog(@" %lu ", (unsigned long)realGoArray.count);
for (int i = 0; i < realGoArray.count; i++) {
MyPoint *pp = realGoArray[i];
XPFLog(@"x = %f , y = %f", pp.pointX, pp.pointY);
}
*/
/*3 -1 4
1 0 0
2 1 -5*/
/*0 1 0
-5 23 -4
-1 5 -1 */
/*
//初始化矩阵
cv::Mat stdfMat = cv::Mat::zeros(3, 3, CV_64F);
cv::Mat stdInvMat = cv::Mat::zeros(3, 3, CV_64F);
// fuzhi
stdfMat.at(0, 0) = 3;
stdfMat.at(0, 1) = -1;
stdfMat.at(0, 2) = 4;
stdfMat.at(1, 0) = 1;
stdfMat.at(1, 1) = 0;
stdfMat.at(1, 2) = 0;
stdfMat.at(2, 0) = 2;
stdfMat.at(2, 1) = 1;
stdfMat.at(2, 2) = -5;
//矩阵求逆
stdInvMat = stdfMat.inv();
for (int i = 0; i < stdInvMat.rows; i++) {
XPFLog(@"%f%f%f", stdInvMat.at(i, 0), stdInvMat.at(i, 1), stdInvMat.at(i, 2));
}
XPFLog(@" ===== ");
//矩阵乘法
cv::Mat tempMat = stdfMat.mul(stdInvMat);//stdfMat * stdInvMat;
for (int j = 0; j < tempMat.rows; j++) {
XPFLog(@"%f%f%f", tempMat.at(j, 0), tempMat.at(j, 1), tempMat.at(j, 2));
}
XPFLog(@" ***** ");
//矩阵乘法
cv::Mat tempMat1 = cv::Mat(3, 3, CV_64F);
cv::gemm(stdfMat, stdInvMat, 1.0, cv::Mat::zeros(3, 3, CV_64F), 0.0, tempMat1);
//cv::multiply(stdfMat, stdInvMat, tempMat1);
for (int j = 0; j < tempMat1.rows; j++) {
XPFLog(@"%f%f%f", tempMat1.at(j, 0), tempMat1.at(j, 1), tempMat1.at(j, 2));
}
XPFLog(@" ===== ");
*/
/*
1 2 2
4 5 8
*/
/*
1 4
2 5
2 8
*/
/*
//转置矩阵
cv::Mat p1Mat = cv::Mat::zeros(2, 3, CV_64F);
p1Mat.at(0, 0) = 1;
p1Mat.at(0, 1) = 2;
p1Mat.at(0, 2) = 2;
p1Mat.at(1, 0) = 4;
p1Mat.at(1, 1) = 5;
p1Mat.at(1, 2) = 8;
cv::Mat p1TMat = p1Mat.t();
for (int j = 0; j < p1TMat.rows; j++) {
XPFLog(@"%f%f", p1TMat.at(j, 0), p1TMat.at(j, 1));//, p1TMat.at(j, 2));
}
*/
/* 1 1 1 2 2 2 */
/* 3 3 3 4 4 4 */
/* 3 3 3 8 8 8 */
/* 3 3 3 2 2 2 */
//矩阵乘
cv::MattempCornerMat =cv::Mat::zeros(2,3,CV_64F);
tempCornerMat.at(0,0) =1;
tempCornerMat.at(0,1) =1;
tempCornerMat.at(0,2) =1;
tempCornerMat.at(1,0) =2;
tempCornerMat.at(1,1) =2;
tempCornerMat.at(1,2) =2;
cv::MatB =cv::Mat::zeros(2,3,CV_64F);
B.at(0,0) =3;
B.at(0,1) =3;
B.at(0,2) =3;
B.at(1,0) =4;
B.at(1,1) =4;
B.at(1,2) =4;
//点乘.*
cv::MattestMulMat = tempCornerMat.mul(B);
cv::MattestDivMat =cv::Mat::zeros(2,3,CV_64F);
//点除./
cv::divide(B, tempCornerMat, testDivMat);
for(intk =0; k < testMulMat.rows; k++) {
XPFLog(@" %f%f%f ", testMulMat.at(k,0), testMulMat.at(k,1), testMulMat.at(k,2));
}
XPFLog(@" ******* ");
for(intm =0; m < testDivMat.rows; m++) {
XPFLog(@" %f%f%f ", testDivMat.at(m,0), testDivMat.at(m,1), testDivMat.at(m,2));
}
/*
cv::Mat eyeMat = cv::Mat::eye(3, 3, CV_64F);
//XPFLog(@"%@", eyeMat);
for (int i = 0; i < eyeMat.rows; i++) {
for (int j= 0; j< eyeMat.cols; j++) {
//XPFLog(@"%d ", eyeMat.at(i,j)[0]);
XPFLog(@"%f ", eyeMat.at(i,j));
}
XPFLog(@" == ");
}
XPFLog(@" ============= ");
eyeMat.at(1, 0) = 3.333;
eyeMat.at(2, 1) = 3.444;
eyeMat.at(0, 1) = 3.555;
for (int i = 0; i < eyeMat.rows; i++) {
for (int j= 0; j< eyeMat.cols; j++) {
//XPFLog(@"%d", eyeMat.at(i,j)[0]);
XPFLog(@"%f ", eyeMat.at(i,j));
}
XPFLog(@" =***= ");
}*/
/*
cv::Mat eyeMat = cv::Mat::eye(4, 4, CV_8UC1);
//XPFLog(@"%@", eyeMat);
for (int i = 0; i < eyeMat.rows; i++) {
for (int j= 0; j< eyeMat.cols; j++) {
//XPFLog(@"%d ", eyeMat.at(i,j)[0]);
XPFLog(@"%d ", eyeMat.at(i,j));
}
XPFLog(@" == ");
}
XPFLog(@" ============= ");
eyeMat.at(2,3) = 3;
for (int i = 0; i < eyeMat.rows; i++) {
for (int j= 0; j< eyeMat.cols; j++) {
//XPFLog(@"%d", eyeMat.at(i,j)[0]);
XPFLog(@"%d ", eyeMat.at(i,j));
}
XPFLog(@" =***= ");
}*/