Advertisement
crackanddie

cpp tests on rpi

Oct 23rd, 2021
153
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.24 KB | None | 0 0
  1. cmake_minimum_required(VERSION 3.0)
  2. project(cpp_proj)
  3.  
  4. # set(CMAKE_CXX_STANDARD 14)
  5.  
  6. find_package(OpenCV REQUIRED)
  7.  
  8. add_executable(cpp_proj opencv_cpp.cpp)
  9.  
  10. include_directories(${OpenCV_INCLUDE_DIRS})
  11. target_link_libraries(cpp_proj ${OpenCV_LIBS})
  12.  
  13. #include <opencv2/opencv.hpp>
  14. #include <iostream>
  15. #include <string>
  16. #include <opencv2/imgcodecs.hpp>
  17. #include <opencv2/core/core.hpp>
  18. #include <opencv2/highgui/highgui.hpp>
  19. #include <opencv2/imgproc/imgproc.hpp>
  20.  
  21. int main() {
  22. const std::string img_file{"logo.png"};
  23.  
  24. // Check if we can open the file
  25. cv::Mat input = cv::imread(img_file, 1);
  26. if(!input.data) {
  27. std::cout << "Can't open file " << img_file << '\n';
  28. return -1;
  29. }
  30.  
  31. // Convert to gray
  32. cv::Mat output;
  33. cvtColor(input, output, cv::COLOR_BGR2GRAY);
  34.  
  35. // Show the original and the result
  36. cv::namedWindow("Original image", cv::WINDOW_AUTOSIZE);
  37. cv::imshow("Original image", input);
  38.  
  39. cv::namedWindow("Gray image", cv::WINDOW_AUTOSIZE);
  40. cv::imshow("Gray image", output);
  41.  
  42. // Wait until the presses any key
  43. cv::waitKey(0);
  44.  
  45. return 0;
  46. }
  47.  
  48. #include <iostream>
  49. using namespace std;
  50.  
  51. int main()
  52. {
  53. cout << "Hello you" << endl;
  54. return 0;
  55. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement