ORL Faces Database介绍
生活随笔
收集整理的這篇文章主要介紹了
ORL Faces Database介绍
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
ORL人臉數據集共包含40個不同人的400張圖像,是在1992年4月至1994年4月期間由英國劍橋的Olivetti研究實驗室創建。
此數據集下包含40個目錄,每個目錄下有10張圖像,每個目錄表示一個不同的人。所有的圖像是以PGM格式存儲,灰度圖,圖像大小寬度為92,高度為112。對每一個目錄下的圖像,這些圖像是在不同的時間、不同的光照、不同的面部表情(睜眼/閉眼,微笑/不微笑)和面部細節(戴眼鏡/不戴眼鏡)環境下采集的。所有的圖像是在較暗的均勻背景下拍攝的,拍攝的是正臉(有些帶有略微的側偏)。
可以從http://www.cl.cam.ac.uk/research/dtg/attarchive/facedatabase.html下載此人臉數據集。
測試代碼如下:
#include "funset.hpp"
#include <iostream>
#include <fstream>
#include <vector>
#include <opencv2/opencv.hpp>int ORLFacestoImage()
{const std::string path{ "E:/GitCode/NN_Test/data/database/ORL_Faces/" };cv::Mat dst;int height, width;for (int i = 1; i <= 40; ++i) {std::string directory = path + "s" + std::to_string(i) + "/";for (int j = 1; j <= 10; ++j) {std::string image_name = directory + std::to_string(j) + ".pgm";cv::Mat mat = cv::imread(image_name, 0);if (!mat.data) {fprintf(stderr, "read image fail: %s\n", image_name.c_str());}//std::string save_image_name = directory + std::to_string(j) + ".png";//cv::imwrite(save_image_name, mat);if (i == 1 && j == 1) {height = mat.rows;width = mat.cols;dst = cv::Mat(height * 20, width * 20, CV_8UC1);}int y_start = (i - 1) / 2 * height;int y_end = y_start + height;int x_start = (i - 1) % 2 * 10 * width + (j - 1) * width;int x_end = x_start + width;cv::Mat copy = dst(cv::Range(y_start, y_end), cv::Range(x_start, x_end));mat.copyTo(copy);}}int new_width = 750;float factor = dst.cols * 1.f / new_width;int new_height = dst.rows / factor;cv::resize(dst, dst, cv::Size(new_width, new_height));cv::imwrite("E:/GitCode/NN_Test/data/orl_faces_dataset.png", dst);return 0;
}
執行結果如下:
GitHub:?https://github.com/fengbingchun/NN_Test ?
總結
以上是生活随笔為你收集整理的ORL Faces Database介绍的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 手机内存RAM、ROM简介
- 下一篇: OpenCV3.3中主成分分析(Prin