Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to build a simple opencv example inside the container? #10

Open
KansaiUser opened this issue Aug 15, 2023 · 0 comments
Open

How to build a simple opencv example inside the container? #10

KansaiUser opened this issue Aug 15, 2023 · 0 comments

Comments

@KansaiUser
Copy link

I have successfully build one of the images in the repo (I had to change the base though since the one here in the repo does not exist anymore)

I want to try it by building a simple example of opencv using cuda. For example

#include <iostream>
#include "opencv2/opencv.hpp"
   
int main (int argc, char* argv[])
{
    //Read Two Images 
    cv::Mat h_img1 = cv::imread("images/cameraman.tif");
    cv::Mat h_img2 = cv::imread("images/circles.png");
    //Create Memory for storing Images on device
    cv::cuda::GpuMat d_result1,d_img1, d_img2;
    cv::Mat h_result1;
    //Upload Images to device     
    d_img1.upload(h_img1);
    d_img2.upload(h_img2);
​
    cv::cuda::add(d_img1,d_img2, d_result1);
    //Download Result back to host
    d_result1.download(h_result1);
    cv::imshow("Image1 ", h_img1);
    cv::imshow("Image2 ", h_img2);
    cv::imshow("Result addition ", h_result1);
    cv::imwrite("images/result_add.png", h_result1);
    cv::waitKey();
    return 0;
}

I tried to build this with

g++ -std=c++11 -o image_addition one.cpppkg-config --cflags --libs opencv

but it failed

Package opencv was not found in the pkg-config search path.
Perhaps you should add the directory containing `opencv.pc'
to the PKG_CONFIG_PATH environment variable
No package 'opencv' found
one.cpp:2:10: fatal error: opencv2/opencv.hpp: No such file or directory
    2 | #include "opencv2/opencv.hpp"
      |          ^~~~~~~~~~~~~~~~~~~~
compilation terminated

so my question is, how do you build opencv source code with your container??
It seems pkg-config does not find opencv

Please advice.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant