Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

how to create bgr file from jpg file? #80

Open
nqthai309 opened this issue Apr 13, 2023 · 1 comment
Open

how to create bgr file from jpg file? #80

nqthai309 opened this issue Apr 13, 2023 · 1 comment

Comments

@nqthai309
Copy link

how to create bgr file from jpg file?
Thanks in advance

@hongson23
Copy link

void savebgr(cv::Mat& img, const char* bgr_path)
{
if (bgr_path)
{
FILE* fp = fopen(bgr_path, "wb");
int step = img.step;
int h = img.rows;
int w = img.cols;
int c = img.channels();
for (int k = 0; k < c; k++)
for (int i = 0; i < h; i++)
for (int j = 0; j < w; j++)
{

				//fwrite(&img.data[i*step + j * c + k], sizeof(uint8_t), 1, fp);
				fwrite(&img.data[c*(i * w + j) + k], sizeof(uint8_t), 1, fp);
			}
	fclose(fp);
}

}

pls refer to https://zhuanlan.zhihu.com/p/107548509

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants