-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
125 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
# Generated from CLion C/C++ Code Style settings | ||
BasedOnStyle: LLVM | ||
AccessModifierOffset: -1 | ||
AlignAfterOpenBracket: Align | ||
AlignConsecutiveAssignments: None | ||
AlignOperands: DontAlign | ||
AllowAllArgumentsOnNextLine: false | ||
AllowAllConstructorInitializersOnNextLine: false | ||
AllowAllParametersOfDeclarationOnNextLine: false | ||
AllowShortBlocksOnASingleLine: Always | ||
AllowShortCaseLabelsOnASingleLine: true | ||
AllowShortFunctionsOnASingleLine: All | ||
AllowShortIfStatementsOnASingleLine: Always | ||
AllowShortLambdasOnASingleLine: All | ||
AllowShortLoopsOnASingleLine: true | ||
AlwaysBreakAfterReturnType: None | ||
AlwaysBreakTemplateDeclarations: Yes | ||
BreakBeforeBraces: Custom | ||
BraceWrapping: | ||
AfterCaseLabel: false | ||
AfterClass: false | ||
AfterControlStatement: Never | ||
AfterEnum: false | ||
AfterFunction: false | ||
AfterNamespace: false | ||
AfterUnion: false | ||
BeforeCatch: false | ||
BeforeElse: false | ||
IndentBraces: false | ||
SplitEmptyFunction: false | ||
SplitEmptyRecord: true | ||
BreakBeforeBinaryOperators: NonAssignment | ||
BreakBeforeTernaryOperators: true | ||
BreakConstructorInitializers: BeforeColon | ||
BreakInheritanceList: BeforeColon | ||
ColumnLimit: 0 | ||
CompactNamespaces: false | ||
ContinuationIndentWidth: 4 | ||
IndentCaseLabels: true | ||
IndentPPDirectives: None | ||
IndentWidth: 2 | ||
KeepEmptyLinesAtTheStartOfBlocks: true | ||
MaxEmptyLinesToKeep: 1 | ||
NamespaceIndentation: None | ||
ObjCSpaceAfterProperty: false | ||
ObjCSpaceBeforeProtocolList: false | ||
PointerAlignment: Right | ||
ReflowComments: false | ||
SpaceAfterCStyleCast: true | ||
SpaceAfterLogicalNot: false | ||
SpaceAfterTemplateKeyword: false | ||
SpaceBeforeAssignmentOperators: true | ||
SpaceBeforeCpp11BracedList: false | ||
SpaceBeforeCtorInitializerColon: true | ||
SpaceBeforeInheritanceColon: true | ||
SpaceBeforeParens: ControlStatements | ||
SpaceBeforeRangeBasedForLoopColon: false | ||
SpaceInEmptyParentheses: false | ||
SpacesBeforeTrailingComments: 0 | ||
SpacesInAngles: false | ||
SpacesInCStyleCastParentheses: false | ||
SpacesInContainerLiterals: false | ||
SpacesInParentheses: false | ||
SpacesInSquareBrackets: false | ||
TabWidth: 4 | ||
UseTab: Never |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
/home/zj/opencv/opencv-4.9.0/install_Release |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
cmake_minimum_required(VERSION 3.24) | ||
project(OpenCVDemo) | ||
|
||
set(CMAKE_CXX_STANDARD 17) | ||
|
||
# set opencv | ||
get_filename_component(ABSOLUTE_OpenCV_DIR ./3rdparty/opencv ABSOLUTE) | ||
IF (CMAKE_SYSTEM_NAME MATCHES "Linux") | ||
set(OpenCV_DIR ${ABSOLUTE_OpenCV_DIR}/lib/cmake/opencv4) | ||
ELSEIF (CMAKE_SYSTEM_NAME MATCHES "Windows") | ||
set(OpenCV_DIR ${ABSOLUTE_OpenCV_DIR}) | ||
ENDIF () | ||
find_package(OpenCV REQUIRED) | ||
|
||
MESSAGE("OpenCV version: ${OpenCV_VERSION}") | ||
MESSAGE("OpenCV OpenCV_INCLUDE_DIRS: ${OpenCV_INCLUDE_DIRS}") | ||
MESSAGE("OpenCV OpenCV_LIBS: ${OpenCV_LIBS}") | ||
|
||
|
||
add_executable(OpenCVDemo main.cpp) | ||
target_link_libraries(OpenCVDemo ${OpenCV_LIBS}) |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
#include <iostream> | ||
|
||
#include "opencv2/opencv.hpp" | ||
|
||
int main() { | ||
// 读取图片 | ||
cv::Mat image = cv::imread("../lena.jpg"); | ||
if (image.empty()) { | ||
std::cout << "无法读取图片,请确保文件路径正确" << std::endl; | ||
return -1; | ||
} | ||
|
||
// 获取图片的尺寸 | ||
int width = image.cols; | ||
int height = image.rows; | ||
|
||
// 计算中心裁剪的区域 | ||
int x = width / 4; // 裁剪区域的左上角 x 坐标 | ||
int y = height / 4; // 裁剪区域的左上角 y 坐标 | ||
int cropWidth = width / 2; // 裁剪区域的宽度 | ||
int cropHeight = height / 2;// 裁剪区域的高度 | ||
|
||
// 裁剪图片 | ||
cv::Rect cropRegion(x, y, cropWidth, cropHeight); | ||
cv::Mat croppedImage = image(cropRegion); | ||
|
||
// 显示原始图片和裁剪后的图片 | ||
cv::imshow("原始图片", image); | ||
cv::imshow("裁剪后的图片", croppedImage); | ||
cv::waitKey(0); | ||
|
||
// 保存裁剪后的图片 | ||
cv::imwrite("../cropped_lena.jpg", croppedImage); | ||
|
||
std::cout << "Hello, World!" << std::endl; | ||
return 0; | ||
} |