Zi 字媒體
2017-07-25T20:27:27+00:00
jashliao 用 VC++ 實現 fanfuhan OpenCV 教學001 ~ opencv-001-讀取(imread)、顯示(imshow)與儲存(imwrite)圖像
資料來源: https://fanfuhan.github.io/
https://fanfuhan.github.io/2019/03/20/opencv-001/
GITHUB: https://github.com/jash-git/fanfuhan_ML_OpenCV
https://github.com/jash-git/jashliao-implements-FANFUHAN-OPENCV-with-VC
★前言:
★主題:
OPENCV基本輸出入函數介紹: 讀取(imread)、顯示(imshow)與儲存(imwrire)
★C++
// VC_FANFUHAN_OPENCV001.cpp : 定義主控台應用程式的進入點。
//
/*
// Debug | x32
通用屬性
| C/C++
| | 一般
| | 其他 Include 目錄 -> C:\opencv\build\include
|
| 連結器
| |一一般
| | 其他程式庫目錄 -> C:\opencv\build\x64\vc15\lib
|
| |一輸入
| | 其他相依性 -> opencv_world411d.lib;%(AdditionalDependencies)
// Releas | x64
組態屬性
| C/C++
| | 一般
| | 其他 Include 目錄 -> C:\opencv\build\include
|
| 連結器
| |一般
| | 其他程式庫目錄 -> C:\opencv\build\x64\vc15\lib
|
| |一輸入
| | 其他相依性 -> opencv_world411.lib;%(AdditionalDependencies)
*/
#include "stdafx.h"
#include
#include
#include
#include
using namespace std;
using namespace cv;
void pause()
{
printf("Press Enter key to continue...");
fgetc(stdin);
}
int main()
{
Mat image = imread("../../images/l_hires.jpg", IMREAD_GRAYSCALE);//IDE 測試路徑
//Mat image = imread("../../../images/l_hires.jpg", IMREAD_GRAYSCALE);//執行檔 測試路徑
if (image.empty()) {
cout << "could not load image..." << endl;
pause();
return -1;
}
else
{
namedWindow("input");
imshow("input", image);
imwrite("output.jpg", image);
waitKey(0);
}
return 0;
}
★Python
import cv2 as cv
src = cv.imread("../images/liuyifei_1.png")
cv.namedWindow("input", cv.WINDOW_AUTOSIZE)
cv.imshow("input", src)
cv.waitKey(0)
cv.destroyAllWindows()
★結果圖:
★延伸說明/重點回顧:
OPENCV基本輸出入函數介紹: 讀取(imread)、顯示(imshow)與儲存(imwrire)
OPENCV在讀取影像時就可以轉灰階圖非常方便
寫了
5860316篇文章,獲得
23313次喜歡