Windows配置ArUco

windows10
vs2019
opencv3.4.6

------------------------------------------------------------------------------------------------------------------------------------------

注意,一定要选择与opencv版本一样的opencv_contrib进行编译,否则将会出现错误,有很多的工程不能编译通过,不能产生相应的lib文件。

下载contrib库

contrib库(下载3.4.6版本):https://github.com/opencv/opencv_contrib/releases

cmake-gui地址(下载最新版3.15.2):http://www.cmake.org/cmake/resources/software.html

用CMake编译OpenCV3.4.6

Windows配置ArUco_第1张图片

点击configure,如果有红的就继续点configure,直到红色都消失

用CMake编译OpenCV_contrib3.4.6

把opencv_contrib-3.4.6文件夹放到C:\opencv目录下,在cmake-gui中找到OPENCV_EXTRA_MODULES_PATH,在它的Value处填入opencv_contrib-3.4.6\modules路径。并勾选OPENCV_ENABLE_NONFREE。

 

然后点击configure,如果报错或者有红的,继续点configure,直到红色都消失

点击generate

用VS2019编译生成debug和release库

  1. 打开C:\opencv\mybuild目录下的OpenCV.sln

  2. 编译debug版本库:在“解决方案'OpenCV'(416个项目)”上面点击右键-->重新生成解决方案。

  3. 找到CMakeTargets中的INSTALL,然后右键选择“仅限于项目”-->“仅生成INSTALL”,然后就在C:\opencv\mybuild\install中发现了许多东东。至此,debug版本的opencv的库文件就安装完成了。release版本的,方法相同,重复2、3即可。

        遇到问题:LNK1104 无法打开文件“python37_d.lib” 解决办法

                          当出现opencv的.dll无法找到的问题的时候用一下处理方法

      4.                   将opencv\build\x*\vc*\bin  复制相应的dll文件到C Windows System32下,这样之后就可以找到了    

重新配置环境


    1.为计算机添加系统变量:C:\opencv\my_build\install\include\x64\vc16\bin  ;
    

    右键电脑【属性】 ,【高级系统设置】 ,【环境变量】 ,  【系统变量】【Path】, 在变量值后加  编译目录\install\x64\vc16\bin 的完整路径 
    
 
    添加用户变量设置:

    变量名:OPENCV变量值:C:\opencv\my_build\install\include
    
    2.属性管理器-->设置-->VC++目录-->包含目录,添加:

C:\opencv\my_build\install\include

C:\opencv\my_build\install\include\opencv

C:\opencv\my_build\install\include\opencv2

    3.VC++目录-->库目录,添加:
          C:\opencv\my_build\install\include\install\x64\vc16\lib
    4.连接器——>输入——>附加依赖项添加库,346是版本opencv3.4.6,lib文件夹下只有好多个.lib,都加入

opencv_aruco346d.lib
opencv_bgsegm346d.lib
opencv_bioinspired346d.lib
opencv_calib3d346d.lib
opencv_ccalib346d.lib
opencv_core346d.lib
opencv_datasets346d.lib
opencv_dnn_objdetect346d.lib
opencv_dnn346d.lib
opencv_dpm346d.lib
opencv_face346d.lib
opencv_features2d346d.lib
opencv_flann346d.lib
opencv_fuzzy346d.lib
opencv_hdf346d.lib
opencv_hfs346d.lib
opencv_highgui346d.lib
opencv_img_hash346d.lib
opencv_imgcodecs346d.lib
opencv_imgproc346d.lib
opencv_line_descriptor346d.lib
opencv_ml346d.lib
opencv_objdetect346d.lib
opencv_optflow346d.lib
opencv_phase_unwrapping346d.lib
opencv_photo346d.lib
opencv_plot346d.lib
opencv_reg346d.lib
opencv_rgbd346d.lib
opencv_saliency346d.lib
opencv_shape346d.lib
opencv_stereo346d.lib
opencv_stitching346d.lib
opencv_structured_light346d.lib
opencv_superres346d.lib
opencv_surface_matching346d.lib
opencv_text346d.lib
opencv_tracking346d.lib
opencv_video346d.lib
opencv_videoio346d.lib
opencv_videostab346d.lib
opencv_xfeatures2d346d.lib
opencv_ximgproc346d.lib
opencv_xobjdetect346d.lib
opencv_xphoto346d.lib

 

测试代码——生成aruco_board


#include 
#include 
#include 
#include 
#include 
#include 
#include 
#include 
#include 

using namespace std;
using namespace cv;

int main()
{
	int markersX = 5;//X轴上标记的数量
	int markersY = 5;//Y轴上标记的数量   本例生成5x5的棋盘
	int markerLength = 100;//标记的长度,单位是像素
	int markerSeparation = 20;//每个标记之间的间隔,单位像素
	int dictionaryId = cv::aruco::DICT_4X4_50;//生成标记的字典ID
	int margins = markerSeparation;//标记与边界之间的间隔
 
	int borderBits = 1;//标记的边界所占的bit位数
	bool showImage = true;

	Size imageSize;

	imageSize.width = markersX * (markerLength + markerSeparation) - markerSeparation + 2 * margins;

	imageSize.height =markersY * (markerLength + markerSeparation) - markerSeparation + 2 * margins;

	Ptr dictionary =aruco::getPredefinedDictionary(aruco::PREDEFINED_DICTIONARY_NAME(dictionaryId));

	Ptr board = aruco::GridBoard::create(markersX, markersY, float(markerLength),float(markerSeparation), dictionary);

	// show created board
	Mat boardImage;
	board->draw(imageSize, boardImage, margins, borderBits);

	if (showImage) {
		imshow("board", boardImage);
		waitKey(0);
	}
	return 0;

}

 

 

 

 

 

 

OpenCV 3.1.0添加opencv_contrib模块(Windows)

OpenCV3.1.0安装配置与OpenCV_contrib库配置

基于VS2015和opencv 3.4.1平台的opencv_contrib配置

WIN10+VS2015+opencv3.4.4+opencv_contrib-3.4.4环境配置

CMake3.11.1+Opencv3.4.0+opencv_contrib3.4+VS2015(vc14)+Win10配置成功

Win10下已经安装opencv,如何再安装opencv_contrib

【OpenCV/aruco】校准相机(Camera Calibration) Demo

你可能感兴趣的:(OpenCV)