关于Mastering-OpenCV3第二版的代码跑通--关于PCL的一些问题

windows10 

cuda_10.1.105_418.96_win10

cudnn-10.1-windows10-x64-v7.6.5.32

opencv-2.4.13.7.tar.gz

vcpkg分支:

e054fe2b20469c894b88be4ac466776f9f653954

编译:

.\vcpkg.exe install opencv2[cuda,png,jpeg]:x64-windows

The following packages will be built and installed:
  * cuda[core]:x64-windows -> 10.1#5
  * eigen3[core]:x64-windows -> 3.3.7#8
  * libjpeg-turbo[core]:x64-windows -> 2.0.5#1
  * liblzma[core]:x64-windows -> 5.2.5#2
  * libpng[core]:x64-windows -> 1.6.37#13
    opencv2[core,cuda,eigen,jpeg,opengl,png,tiff]:x64-windows -> 2.4.13.7#4
  * opengl[core]:x64-windows -> 0.0#8
  * tiff[core]:x64-windows -> 4.1.0
  * zlib[core]:x64-windows -> 1.2.11#9

VS2019 English语言 

测试:

#include <iostream>
#include "opencv2/opencv.hpp"
#include "opencv2/gpu/gpu.hpp"

int main(int argc, char* argv[])
{
	try
	{
		cv::Mat src_host = cv::imread("./0000.png", CV_LOAD_IMAGE_GRAYSCALE);
		cv::gpu::GpuMat dst, src;
		src.upload(src_host);

		cv::gpu::threshold(src, dst, 128.0, 255.0, CV_THRESH_BINARY);

		cv::Mat result_host;
		dst.download(result_host);
		cv::imshow("Result", result_host);
		cv::waitKey();
	}
	catch (const cv::Exception& ex)
	{
		std::cout << "Error: " << ex.what() << std::endl;
	}
	return 0;
}

PCL github下载:

PCL 1.11.1

最后遇到bug:

CMake Error at D:/new_code/opencv2/vcpkg-e054/scripts/buildsystems/vcpkg.cmake:445 (_add_executable):
  Target "ExploringSfMExec" links to target "Threads::Threads" but the target
  was not found.  Perhaps a find_package() call is missing for an IMPORTED
  target, or an ALIAS target is missing?
Call Stack (most recent call first):
  CMakeLists.txt:61 (add_executable)

完全解决不了

删除这个lib

去掉Visualization.cpp Visualization.h

	//pcl::toROSMsg(mesh_cld,pm.cloud);
	pcl::toPCLPointCloud2(mesh_cld, pm.cloud);
	//pcl::fromPCLPointCloud2(pm.cloud, mesh_cld);

注释main.cpp中pcl代码

Common.cpp

#ifndef WIN32
#include <dirent.h>
#else
#include <windows.h>
#endif

GPUSURFFeatureMatcher.h 

#include "IFeatureMatcher.h"
#include <opencv2/gpu/gpu.hpp>
#include <opencv2/nonfree/gpu.hpp>

开启 __SFM__DEBUG__后不要使用GPU会奔溃

RICH GPU

RICH CPU

OF GPU

OF CPU

下面是另外一条路,别去弄了,不方便

https://blog.csdn.net/baidu_40840693/article/details/83718819


https://github.com/PacktPublishing/Mastering-OpenCV3-Second-Edition

他以前的版本是:

https://github.com/MasteringOpenCV/code

 

具体环境配置参考我上一篇博文:

https://blog.csdn.net/baidu_40840693/article/details/115284208

上一篇我们已经安装好了opencv4 vtk9.0

我们在  vcpkg-e054fe2b20469c894b88be4ac466776f9f653954  分支上继续编译pcl

遇到了一个问题:

Building package kinectsdk1[core]:x64-windows...
-- Using cached D:/new_code/vcpkg-e054/downloads/KinectSDK-v1.8-Setup.exe
CMake Error at scripts/cmake/vcpkg_download_distfile.cmake:105 (message):


  File does not have expected hash:

          File path: [ D:/new_code/vcpkg-e054/downloads/KinectSDK-v1.8-Setup.exe ]
      Expected hash: [ ee8a0f70c86aad80fe214108e315e4550a90ed39f278ce00a7137532174ee5bf3bdeb1d0b499fc5ffdb5e176adecfd68963ee3731e1d2f00d69d32d1b8a3c555 ]
        Actual hash: [ d7e886d639b4310addc7c1350311f81289ffbcd653237882da7bf3d4074281ed35d217cb8be101579cac880c574dd89c62cd6a87772d60905c446d0be5fd1932 ]

  Please delete the file and retry if this file should be downloaded again.

Call Stack (most recent call first):
  scripts/cmake/vcpkg_download_distfile.cmake:118 (test_hash)
  ports/kinectsdk1/portfile.cmake:6 (vcpkg_download_distfile)
  scripts/ports.cmake:136 (include)

解决方案:

https://github.com/microsoft/vcpkg/tree/62f5be4fab1c37ff245e506d501d4cde5215845d

https://github.com/microsoft/vcpkg/pull/15856

diff对照修改我们自己分支的几个文件:

修改:

~\ports\kinectsdk1\portfile.cmake

~\ports\kinectsdk1\vcpkg.json

~\versions\k-\kinectsdk1.json

~\versions\baseline.json

删除:

~\ports\kinectsdk1\CONTROL

不用管上面的分支,只需要修改我们分支的~\ports\kinectsdk1\portfile.cmake

就会解决

接着我遇到了如下bug

Starting package 2/4: openni2:x64-windows
Building package openni2[core]:x64-windows...
CMake Error at ports/openni2/portfile.cmake:7 (message):
  Could not find <cor.h>.  Ensure the NETFXSDK is installed.
Call Stack (most recent call first):
  scripts/ports.cmake:136 (include)


Error: Building package openni2:x64-windows failed with: BUILD_FAILED

解决方案:

https://github.com/microsoft/vcpkg/issues/12039

https://github.com/microsoft/vcpkg/issues/14550

原因是我的windwos-SDK安装不全

搞定~~

 

然后下载ssba-3.0代码放在3rdparty

执行cmake 该库用到了pcl opencv ssba等,我们的vcpkg里面已经有了

cmake . ..\src -G "Visual Studio 16 2019" -DCMAKE_TOOLCHAIN_FILE=D:\new_code\vcpkg-e054\scripts\buildsystems\vcpkg.cmake -DVCPKG_TARGET_TRIPLET=x64-windows

代码中遇到

遇到 'HANDLE': undeclared identifier的bug

我才想起来vs2019没有安装MFC相关的东西

安装它

还有一些bug,参考github

https://github.com/MasteringOpenCV/code/issues/12

#include <windows.h>

https://github.com/MasteringOpenCV/code/issues/79

https://github.com/MasteringOpenCV/code/issues/68

 

看debug结果记得开启预编译头

 

 

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值