小编Ja_*_*cpp的帖子

将外部库添加到CMakeList.txt c ++

我有我的外部库,如下图所示,我创建了符号链接:

在此输入图像描述

以及与其他文件中的库相关的标题:

在此输入图像描述

我正在使用ROS ubuntu,我需要将这些库添加到我的包中CmakeList.txt:

cmake_minimum_required(VERSION 2.4.6)
include($ENV{ROS_ROOT}/core/rosbuild/rosbuild.cmake)

rosbuild_init()

#set the default path for built executables to the "bin" directory
set(EXECUTABLE_OUTPUT_PATH ${PROJECT_SOURCE_DIR}/bin)
#set the default path for built libraries to the "lib" directory
set(LIBRARY_OUTPUT_PATH ${PROJECT_SOURCE_DIR}/lib)

#common commands for building c++ executables and libraries
#rosbuild_add_library(${PROJECT_NAME} src/example.cpp)
#target_link_libraries(${PROJECT_NAME} another_library)
#rosbuild_add_boost_directories()
#rosbuild_link_boost(${PROJECT_NAME} thread)
#rosbuild_add_executable(example examples/example.cpp)
#target_link_libraries(example ${PROJECT_NAME})

rosbuild_add_executable(kinectueye src/kinect_ueye.cpp)
Run Code Online (Sandbox Code Playgroud)

所以我的问题是如何将这些文件夹(我认为我需要添加的第一个我不确定)添加到我的CmakeList.txt文件中,以便我可以使用我的程序中的类和方法.

c++ cmake libraries

29
推荐指数
1
解决办法
11万
查看次数

CMake错误:变量设置为NOTFOUND

我首先使用cuda安装cuda-repo-ubuntu1604-9-0-local_9.0.176-1_amd64.deb.现在我正在尝试安装OpenCV 3.3.0但是我得到了CMake错误:

CMake Error: The following variables are used in this project, but they are set to NOTFOUND.
Please set them or make sure they are set and tested correctly in the CMake files:
CUDA_nppi_LIBRARY (ADVANCED)
Run Code Online (Sandbox Code Playgroud)

然后是很长的目标列表,如下所示:

linked by target "opencv_cudev" in directory /home/jjros/opencv-3.3.0/modules/cudev
Run Code Online (Sandbox Code Playgroud)

我正在使用此命令来编译库:

cmake 

-D CMAKE_C_COMPILER=/usr/bin/gcc-5 \ 
-D CMAKE_BUILD_TYPE=RELEASE \   
-D CMAKE_INSTALL_PREFIX=/usr/local \     
-D WITH_CUDA=ON \     
-D WITH_CUBLAS=ON \     
-D WITH_TBB=ON \    
-D WITH_V4L=ON \    
-D WITH_QT=ON \     
-D WITH_OPENGL=ON \    
-D ENABLE_FAST_MATH=1 \ …
Run Code Online (Sandbox Code Playgroud)

opencv cuda cmake ubuntu-16.04

23
推荐指数
1
解决办法
3万
查看次数

编译OpenCV 3.3:不支持C++ 11

我正在尝试编译新版本OpenCV 3.3(2017年8月3日发布),但我收到了错误C++11

这是我的cmake命令行:

cmake -D CMAKE_BUILD_TYPE=RELEASE \ 
-D CMAKE_INSTALL_PREFIX=/usr/local \    
-D WITH_CUDA=ON \    
-D ENABLE_FAST_MATH=1 \    
-D CUDA_FAST_MATH=1 \    
-D WITH_CUBLAS=1 \    
-DINSTALL_C_EXAMPLES=OFF \    
-D INSTALL_PYTHON_EXAMPLES=ON \    
-D OPENCV_EXTRA_MODULES_PATH=../../opencv_contrib-3.3/modules \    
-D BUILD_SHARED_LIBS=ON \    
-D WITH_GTK=ON /    
-D BUILD_EXAMPLES=ON ..
Run Code Online (Sandbox Code Playgroud)

我通过打开一些组件来编辑CMakeLists(即使没有做任何更改,错误也保持不变):

OCV_OPTION(WITH_OPENGL         "Include OpenGL support"                      ON  IF (NOT ANDROID AND NOT WINRT) )
OCV_OPTION(WITH_OPENVX         "Include OpenVX support"                      ON)
OCV_OPTION(WITH_OPENNI         "Include OpenNI support"                      ON  IF (NOT ANDROID AND NOT IOS AND NOT WINRT) )
OCV_OPTION(WITH_OPENNI2        "Include OpenNI2 …
Run Code Online (Sandbox Code Playgroud)

opencv compilation cmake c++11 ubuntu-16.04

18
推荐指数
1
解决办法
2万
查看次数

cv::parallel_for_ 改进不大

我正在测试该类cv::ParallelLoopBody的图像处理代码。

我首先开始实现归一化,在那里我必须为每个通道划分具有特定值的所有像素,这是一个简单的并行代码。

但是,在测试它时,我没有看到任何区别。

我在这里做错了吗?

这是我的课:

class Parallel_process : public cv::ParallelLoopBody
    {

    private:
        cv::Mat img; //my image to normalize
        std::vector<int> A;
        int diff;

    public:
        Parallel_process(cv::Mat inputImage, std::vector<int> AA, int diffVal)
                           : img(inputImage), A(AA), diff(diffVal){}

        virtual void operator()(const cv::Range& range) const
        {
            for(int i = range.start; i < range.end; i++)
            {
              //in is a patch of my original image
               cv::Mat in(img, cv::Rect(0, (img.rows/diff)*i, img.cols, img.rows/diff));
               std::vector<int> AAA (A);
               in.forEach<cv::Vec3f>
                (
                  [&AAA](cv::Vec3f &pixel, const int* po) -> void
                  {
                    pixel[0]/=AAA[0];
                    pixel[1]/=AAA[1]; …
Run Code Online (Sandbox Code Playgroud)

c++ parallel-processing lambda opencv parallelism-amdahl

5
推荐指数
0
解决办法
762
查看次数

更新g ++但仍然是旧版本

我用这些命令行安装了g ++:

sudo add-apt-repository ppa:jonathonf/gcc-7.1 
sudo apt-get update
Run Code Online (Sandbox Code Playgroud)

然后

sudo apt-get install gcc-7 g++-7
Run Code Online (Sandbox Code Playgroud)

当它完成后我尝试g++ -v但仍然显示旧版本

gcc version 5.4.0 20160609 (Ubuntu 5.4.0-6ubuntu1~16.04.4)
Run Code Online (Sandbox Code Playgroud)

我没有正确升级吗?

编辑

:~$ dpkg -L g++-7

/.
/usr
/usr/lib
/usr/lib/gcc
/usr/lib/gcc/x86_64-linux-gnu
/usr/lib/gcc/x86_64-linux-gnu/7
/usr/lib/gcc/x86_64-linux-gnu/7/cc1plus
/usr/share
/usr/share/doc
/usr/share/doc/gcc-7-base
/usr/share/doc/gcc-7-base/C++
/usr/share/doc/gcc-7-base/C++/README.C++
/usr/share/doc/gcc-7-base/C++/changelog.gz
/usr/share/man
/usr/share/man/man1
/usr/share/man/man1/x86_64-linux-gnu-g++-7.1.gz
/usr/bin
/usr/bin/x86_64-linux-gnu-g++-7
/usr/share/doc/g++-7
/usr/share/man/man1/g++-7.1.gz
/usr/bin/g++-7


:~$ which g++

/usr/bin/g++
Run Code Online (Sandbox Code Playgroud)

c++ g++ upgrade

3
推荐指数
1
解决办法
5669
查看次数

错误:没有匹配函数调用std :: thread

我试图运行一个dcp在线程中调用的函数,我必须独立运行该函数三次。所以这是我的实现方式:

void dcp(cv::Mat&, int, int, cv::Mat&, double);

int main(int argc, char* argv[])
{
cv::Mat IllumTrans;
//fill IllumTrans

std::vector<cv::Mat> rgbDCP;
rgbDCP.reserve(3);
//Fill it

std::thread thread_1(dcp, rgb[0], rows, cols, IllumTrans, A[0]);
std::thread thread_2(dcp, rgb[1], rows, cols, IllumTrans, A[1]);
std::thread thread_3(dcp, rgb[2], rows, cols, IllumTrans, A[2]);

thread_1.join();
thread_2.join();
thread_3.join();
}
Run Code Online (Sandbox Code Playgroud)

但是我得到了没有匹配函数的错误调用:

In file included from 21022018WorksfineOneimageThread.cpp:6:0:
/usr/include/c++/7/thread: In instantiation of ‘struct std::thread::_Invoker<std::tuple<void (*)(cv::Mat&, int, int, cv::Mat&, double), cv::Mat, int, int, cv::Mat, int> >’:
/usr/include/c++/7/thread:127:22:   required from ‘std::thread::thread(_Callable&&, _Args&& ...) [with _Callable …
Run Code Online (Sandbox Code Playgroud)

c++ multithreading stdthread

1
推荐指数
1
解决办法
3284
查看次数

为什么 std::for_each 比 __gnu_parallel::for_each 快

我试图理解为什么std::for_each在单线程上运行的~3速度比__gnu_parallel::for_each下面的例子快几倍:

Time =0.478101 milliseconds
Run Code Online (Sandbox Code Playgroud)

对比

Time =0.166421 milliseconds
Run Code Online (Sandbox Code Playgroud)

这是我用来进行基准测试的代码:

#include <iostream>
#include <chrono>
#include <parallel/algorithm>

//The struct I'm using for timming
struct   TimerAvrg
{
    std::vector<double> times;
    size_t curr=0,n;
    std::chrono::high_resolution_clock::time_point begin,end;
    TimerAvrg(int _n=30)
    {
        n=_n;
        times.reserve(n);
    }

    inline void start()
    {
        begin= std::chrono::high_resolution_clock::now();
    }

    inline void stop()
    {
        end= std::chrono::high_resolution_clock::now();
        double duration=double(std::chrono::duration_cast<std::chrono::microseconds>(end-begin).count())*1e-6;
        if ( times.size()<n)
            times.push_back(duration);
        else{
            times[curr]=duration;
            curr++;
            if (curr>=times.size()) curr=0;}
    }

    double getAvrg()
    {
        double sum=0;
        for(auto t:times)
            sum+=t;
        return sum/double(times.size());
    }
}; …
Run Code Online (Sandbox Code Playgroud)

c++ parallel-processing stl

0
推荐指数
1
解决办法
562
查看次数

下载在线视频js

我不知道这是问这样的问题是否合适,但我想下载我的毕业典礼的在线视频。我尝试查找源代码并在谷歌浏览器中检查选项,但没有成功。有什么办法可以下载视频吗?

html video.js

0
推荐指数
1
解决办法
9363
查看次数