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

📄 imgview.c

📁 ov7660摄像头模块的测试程序
💻 C
字号:
#include <stdio.h>#include <fcntl.h>//#include <fb.h>#include <sys/mman.h>#include "type.h"#define  QVGA_SIZE    320*240*2#define  SKIPROW      0#define  SKIPCOL      0static double msecond(){	struct timeval tv;	gettimeofday(&tv, 0);	return (tv.tv_sec * 1.0e3 + tv.tv_usec * 1.0e-3);}int main(){	int i, j;	int fd_csi2c;	int fb;	int ret;		double enctime;				unsigned char buff[QVGA_SIZE];	unsigned char dispbuf[QVGA_SIZE];	unsigned char tmpbuf[1024] = {0};	unsigned short *pbuff;	unsigned short *ptr;		if ((fd_csi2c = open("/dev/csi2c", O_RDWR)) < 0)	{		printf("Device csi2c open error !\n");		exit(-1);	}	if ((fb = open("/dev/fb0", O_RDWR)) < 0)	{		printf("Device mem device !\n");		exit(-1);	}				pbuff = mmap(NULL, QVGA_SIZE, PROT_READ | PROT_WRITE, MAP_SHARED, fb, 0);	if(pbuff==NULL)	{	    printf("Map errror\n");	}	while(1)	{	    enctime = msecond();	    	    if ((ret = read(fd_csi2c, buff, QVGA_SIZE)) < 0)	    	printf("bad frame!\n");	    	    memcpy(dispbuf+SKIPROW*640,buff,(240-SKIPROW)*640);	    memcpy(dispbuf+640,buff+(240-SKIPROW)*640,SKIPROW*640);	    	    for(i=0;i<240;i++)	    {		memcpy(tmpbuf,dispbuf+i*640+SKIPCOL,640-SKIPCOL);		memcpy(tmpbuf+640-SKIPCOL,dispbuf+i*640,SKIPCOL);		memcpy(dispbuf+i*640,tmpbuf,640);	    }	       	    ptr = (unsigned short *)dispbuf;	    	    for(i=0;i<240;i++)    	    {	        for(j=0;j<320;j++)	        {	            pbuff[j*240 + i ]= *ptr++;	        }	    }	    	    enctime = msecond() - enctime;	    printf("fp=%6.2fms\n",enctime);	    for(i=0;i<1000;i++);		    	}		return 0;}

⌨️ 快捷键说明

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