⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 main.cpp

📁 linux和arm下usb摄像头图像的获取
💻 CPP
字号:
#include "camera.h"
#include <stdio.h>
#include <fcntl.h>
int main(void)
{
	char *imageBuf;
	int readBytes;	
	int fd;
	char fileName[20];
	FILE *fp;
	imageBuf = NULL;
	readBytes = 0;
	Camera cam(0, 320, 240, VIDEO_PALETTE_JPEG, methodRead);
	for(; imageBuf == NULL;)
	{
		printf("allocate memory for image buffer\n");
		imageBuf = (char *)malloc(25 * 1024);
	}
	
	cam.openCamera();
	for(;;)
	{
		memset(fileName, 0, sizeof (fileName));
		printf("Please input a file name to save the image:");
		scanf("%s", fileName);
		readBytes = cam.readFrame(imageBuf);
		printf("readBytes = %d\n", readBytes);

		/*fd = open(fileName, O_WRONLY);		
		//write(fd, imageBuf, readBytes);
		printf("filename=%s, fd=%d, size=%d\n", fileName, fd, write(fd, imageBuf, readBytes));
		close(fd);*/

		fp = fopen(fileName, "wb+");
		fwrite(imageBuf, readBytes, 1, fp);
		fclose(fp);
	}
	
	cam.closeCamera();
	
	return 0;
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -