2019.03.04
- 使用system(“pause”)没有图,用waitKey(0)就有图
2019.03.10
- 0x00007FFECDC45549 处(位于 Chapter6.exe 中)引发的异常: Microsoft C++ 异常: cv::Exception,位于内存位置 0x000000CCEE8FD908 处,引发异常的原因是定义了Mat g_srcImage之后又再次定义Mat g_srcImage
- g_nErodeDilateNum赋值写成了g_nElementShape赋值,MorphologyEx.cpp
2019.03.11
g_srcImage.copyTo(g_dstImage);//复制图片
cvtColor(g_srcImage, g_grayImage, COLOR_BayerRG2GRAY);//彩色转换成灰度图
setMouseCallback("效果图", onMouse, 0); //设置鼠标回调
resize(srcImage, dstImage1, Size(), 0.5, 0.5); //图片的缩放
pyrUp(tmpImage, dstImage1, Size(tmpImage.cols * 2, tmpImage.rows * 2));
pyrDown(tmpImage, dstImage1, Size(tmpImage.cols / 2, tmpImage.rows / 2));
resize(tmpImage, dstImage2, Size(tmpImage.cols * 2, tmpImage.rows * 2), (0, 0), (0, 0), 3);
2019.03.12
//CV_64F =6; CV_32F=5;CV_16U=2;CV_8U=0;CV_16S=3 CV_32FC1 = 5
2019.03.14
int x=rng.uniform((int)0,(int)255) //生成一个0到255之间的随机数
Mat threshold_output;
/***************查找轮廓*************/
vector<vector<Point>> contours;
vector<Vec4i> hierachy;
threshold(g_grayImage, threshold_output, g_nThresh, 255, THRESH_BINARY);
findContours(threshold_output, contours, hierachy, RETR_TREE, CHAIN_APPROX_SIMPLE, Point(0, 0));
2019.03.15
- 获取摄像头ID及名称可以用DirectShow,有可能用能的库
Strmiids.lib Quartz.lib
2019.03.19
相机的矫正
#include "opencv2/opencv.hpp"
#include <iostream>
using namespace cv;
using namespace std;
int main()
{
Mat frame;
Mat frameCalibration;
frame = imread("sq.png");
Mat cameraMatrix = Mat::eye(3, 3, CV_64F);
cameraMatrix.at<double>(0, 0) = 60.8453923607402;
cameraMatrix.at<double>(0, 1) = 0;
cameraMatrix.at<double>(0, 2) = 315.494948565862;
cameraMatrix.at<double>(1, 1) = 60.8472861755974;
cameraMatrix.at<double>(1, 2) = 265.947489027123;
Mat distCoeffs = Mat::zeros(5, 1, CV_64F);
distCoeffs.at<double>(0, 0) = -0.00227397511535132;
distCoeffs.at<double>(1, 0) = 3.12234955033044e-06;
distCoeffs.at<double>(2, 0) = 0;
distCoeffs.at<double>(3, 0) = 0;
distCoeffs.at<double>(4, 0) = 0;
undistort(frame, frameCalibration, cameraMatrix, distCoeffs);
imshow("Origianl", frame);
imshow("Calibration", frameCalibration);
waitKey(0);
}