opencv 읽기 raw 형식

1025 단어 필기코드
cv::Mat readRawDataImage(std::string imageName, int rawDataHeight, int rawDataWidth)
{
	FILE *filePointer;

	fopen_s(&filePointer, imageName.c_str(), "rb+");
	if (filePointer == NULL)
	{
		std::cout << "Can not open the raw data!
"; return cv::Mat(); } cv::Mat rawData(rawDataHeight, rawDataWidth, CV_8UC1, cv::Scalar(0)); // read imgae data for (int i = 0; i < rawDataHeight; i++) { uchar *pointer = rawData.ptr(i); fread(pointer, 1, rawDataWidth, filePointer); } fclose(filePointer); return rawData; }
	int rawDataHeight = 6400;
	int rawDataWidth = 6144;

	// Load image
	std::string imageName = "IMG_20191130_194049338.raw";
	cv::Mat rawImage = readRawDataImage(imageName, rawDataHeight, rawDataWidth);

	//// Raw data to Gray using opencv 
	//cv::Mat grayImage;
	//cv::cvtColor(rawImage, grayImage, cv::COLOR_BayerGB2GRAY/*cv::COLOR_BayerGB2BGR_EA*/);

	cv::imshow("test", rawImage);

좋은 웹페이지 즐겨찾기