Add json library from nlohmann's github repository
This commit is contained in:
parent
0c09982827
commit
f85d430a5f
|
@ -0,0 +1,3 @@
|
|||
{
|
||||
"C_Cpp.default.configurationProvider": "ms-vscode.cmake-tools"
|
||||
}
|
|
@ -0,0 +1,18 @@
|
|||
cmake_minimum_required(VERSION 3.0.0)
|
||||
project(OpenCV_test6 VERSION 1.0.0)
|
||||
|
||||
#Find the opencv package
|
||||
find_package(OpenCV REQUIRED)
|
||||
|
||||
#include directories for opencv
|
||||
include_directories(${OpenCV_INCLUDE_DIRS})
|
||||
|
||||
add_executable(${PROJECT_NAME} main.cpp)
|
||||
|
||||
#Add command to generate .gitignore
|
||||
add_custom_command(TARGET ${PROJECT_NAME}
|
||||
COMMAND echo \"*\" > ${CMAKE_BINARY_DIR}/.gitignore
|
||||
COMMAND echo \"**/*\" > ${CMAKE_BINARY_DIR}/.hgignore)
|
||||
|
||||
#Add OpenCV Libraries
|
||||
target_link_libraries(${PROJECT_NAME} ${OpenCV_LIBS})
|
|
@ -0,0 +1,55 @@
|
|||
#include <opencv2/opencv.hpp>
|
||||
#include <iostream>
|
||||
|
||||
using namespace cv;
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
std::string filename;
|
||||
Mat image, gray_image, thre_image;
|
||||
int brightless = 0;
|
||||
|
||||
// Get Filename
|
||||
std::cout << "Input Filename:";
|
||||
std::cin >> filename;
|
||||
|
||||
// Load the image
|
||||
if (filename != "")
|
||||
{
|
||||
image = imread(filename, IMREAD_COLOR);
|
||||
if (image.empty())
|
||||
{
|
||||
std::cout << "Failed to open the image!" << std::endl;
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
// Convert the image to HSV color and filter the background color
|
||||
cvtColor(image, gray_image, COLOR_BGR2GRAY);
|
||||
namedWindow("Original Image", WINDOW_AUTOSIZE);
|
||||
imshow("Original Image", image);
|
||||
namedWindow("Gray Image", WINDOW_AUTOSIZE);
|
||||
imshow("Gray Image", gray_image);
|
||||
|
||||
// Use cv::thershold to convert
|
||||
threshold(gray_image, thre_image, 0, 255, THRESH_BINARY|THRESH_OTSU);
|
||||
namedWindow("OTSU Threshold", WINDOW_AUTOSIZE);
|
||||
imwrite("/dev/shm/test.png", thre_image);
|
||||
imshow("OTSU Threshold", thre_image);
|
||||
|
||||
while (1)
|
||||
{
|
||||
int c = waitKey(1);
|
||||
if (c != -1)
|
||||
{
|
||||
std::cout << c << std::endl;
|
||||
}
|
||||
if (c == 27)
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
destroyAllWindows();
|
||||
return 0;
|
||||
}
|
|
@ -0,0 +1,3 @@
|
|||
{
|
||||
"C_Cpp.default.configurationProvider": "ms-vscode.cmake-tools"
|
||||
}
|
|
@ -0,0 +1,18 @@
|
|||
cmake_minimum_required(VERSION 3.0.0)
|
||||
project(OpenCV_test8 VERSION 1.0.0)
|
||||
|
||||
#Find the opencv package
|
||||
find_package(OpenCV REQUIRED)
|
||||
|
||||
#include directories for opencv
|
||||
include_directories(${OpenCV_INCLUDE_DIRS})
|
||||
|
||||
add_executable(${PROJECT_NAME} main.cpp)
|
||||
|
||||
#Add command to generate .gitignore
|
||||
add_custom_command(TARGET ${PROJECT_NAME}
|
||||
COMMAND echo \"*\" > ${CMAKE_BINARY_DIR}/.gitignore
|
||||
COMMAND echo \"**/*\" > ${CMAKE_BINARY_DIR}/.hgignore)
|
||||
|
||||
#Add OpenCV Libraries
|
||||
target_link_libraries(${PROJECT_NAME} ${OpenCV_LIBS})
|
|
@ -0,0 +1,44 @@
|
|||
#include <opencv2/opencv.hpp>
|
||||
#include <iostream>
|
||||
|
||||
using namespace cv;
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
Mat canvas = Mat::zeros(512, 512, CV_8UC3);
|
||||
RNG rng1(12345);
|
||||
int w = canvas.cols;
|
||||
int h = canvas.rows;
|
||||
namedWindow("Color test", WINDOW_AUTOSIZE);
|
||||
|
||||
while (1)
|
||||
{
|
||||
int c = waitKey(30);
|
||||
if (c != -1)
|
||||
{
|
||||
std::cout << c << std::endl;
|
||||
}
|
||||
if (c == 27)
|
||||
{
|
||||
break;
|
||||
}
|
||||
// Clear the canvas
|
||||
canvas = Scalar(0,0,0);
|
||||
|
||||
// Get position and color
|
||||
int x1 = rng1.uniform(0,w);
|
||||
int y1 = rng1.uniform(0,h);
|
||||
int x2 = rng1.uniform(0,w);
|
||||
int y2 = rng1.uniform(0,h);
|
||||
int r = rng1.uniform(0,255);
|
||||
int g = rng1.uniform(0,255);
|
||||
int b = rng1.uniform(0,255);
|
||||
|
||||
// Draw lines
|
||||
line(canvas, Point(x1, y1), Point(x2, y2), Scalar(r,g,b), 2, LINE_AA, 0);
|
||||
imshow("Color test", canvas);
|
||||
}
|
||||
|
||||
destroyAllWindows();
|
||||
return 0;
|
||||
}
|
|
@ -0,0 +1,12 @@
|
|||
# Put it at your home dir
|
||||
|
||||
# Visual Studio Code Caches
|
||||
rm -rf .config/Code/User/workspaceStorage
|
||||
rm -rf .cache/vscode-cpptools/ipch
|
||||
|
||||
# yay caches
|
||||
rm -rf .cache/yay/*
|
||||
rm -rf .local/share/flatpak/*
|
||||
|
||||
# cache generated by wine QQ
|
||||
rm -rf '文档/Tencent Files'
|
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue