CMake将BLAS添加到项目

时间:2018-10-25 01:42:54

标签: cmake

我正在尝试使用dlib和opencv编译项目。我是CMake的新手。它需要一个BLAS库。我已经安装了ATLAS,我已经尝试了几件事,但是没有发现我可以使用的任何东西。有没有办法找到已安装的BLAS软件包并将其添加到Linux(Ubuntu 18.04)?任何帮助将不胜感激。

错误

enter image description here

main.cpp

#include <iostream> 
#include <dlib/pixel.h>
#include <dlib/opencv.h>
#include <opencv2/opencv.hpp>
#include <dlib/image_processing.h>
#include <dlib/image_processing/frontal_face_detector.h>

using namespace cv;
using namespace std;

int main(int argc, char** argv) 
{
    cv::Mat frame, half;
    cv::VideoCapture cap;
    dlib::array2d<dlib::bgr_pixel> dlibFrame;

    try
    {
        cap.open(2);
    }
    catch(std::exception& e)
    {
        std::cout << e.what() << std::endl;
        return 1;
    }

    dlib::frontal_face_detector detector;

    try
    {
        std::vector<dlib::rectangle> faces;
        cv::namedWindow("Tracking Window");

        while(cap.isOpened())
        {
             cap >> frame;
             cv::resize(frame,half,cv::Size(),0.5,0.5); 
             dlib::assign_image(dlibFrame,dlib::cv_image<dlib::bgr_pixel>(half));

             faces = detector(dlibFrame);

             for(size_t i = 0;i < faces.size();++i)
             {
                 auto& r = faces[i];
                 cv::Rect cvr = cv::Rect(r.left(),r.top(),r.width(),r.height());

                 cv::rectangle(half,cvr,cv::Scalar(255,0,0),2);
             }

             cv::imshow("Tracking Window",half); 

             if(cv::waitKey(1) == 27)
                break;
        }
    }
    catch(std::exception& e)
    {
        cout << e.what() << endl;
        return 1;
    }

    cv::destroyAllWindows();

    return 0;
}

CMake

cmake_minimum_required(VERSION 3.0.0)
project(ObjectTracking VERSION 0.1.0)

include(CTest)
enable_testing()

add_executable(ObjectTracking main.cpp)

find_package(BLAS REQUIRED)
find_package(OpenCV REQUIRED)
find_package(dlib REQUIRED)

target_link_libraries(ObjectTracking ${OpenCV_LIBS} dlib ${BLAS_LIBRARIES})

set(CPACK_PROJECT_NAME ${PROJECT_NAME})
set(CPACK_PROJECT_VERSION ${PROJECT_VERSION})
include(CPack)

1 个答案:

答案 0 :(得分:0)

对于Ubuntu 18.04,有以下软件包:

  • libblas-dev
  • libbas3
  • libcblas2
  • libcublas9.1(如果您有Nvidia GPU和CUDA?)

我使用的是OpenBLAS,所以我对使用哪一个不太满意。

一种替代方法是OpenBLAS。仓库位于:https://github.com/xianyi/OpenBLAS.git

要构建它:

  1. git clone https://github.com/xianyi/OpenBLAS.git
  2. cd OpenBLAS
  3. sudo进行安装

OpenBLAS检测到您的CPU并创建适当的二进制文件。

相关问题