search
尋找貓咪~QQ 地點 桃園市桃園區 Taoyuan , Taoyuan

jashliao 用 VC++ 實現 fanfuhan OpenCV 教學001 ~ opencv-001-讀取(imread)、顯示(imshow)與儲存(imwrite)圖像 – jash

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在讀取影像時就可以轉灰階圖非常方便



熱門推薦

本文由 jashliaoeuwordpress 提供 原文連結

寵物協尋 相信 終究能找到回家的路
寫了7763篇文章,獲得2次喜歡
留言回覆
回覆
精彩推薦