USB摄像头一般可以用VIDEO 4 LINUX 2来获取,一般获取到的是YUV420格式的像素矩阵。
JPEG的压缩可以用libjpeg
参考ln -l命令的输出结果,编写了以下程序(即输出结果和ls -l命令的输出结果相似),通过命令行传入要查看的目录,如果没有传入参数,则显出当前目录:#include <unistd.h>
#include <sys/stat.h>
#include <sys/types.h>
#include <dirent.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <pwd.h>
#include <time.h>
char *getmod(mode_t mode,char *line) /*生成权限描述字符串*/
{
memset(line,0,sizeof(char)*11)
strcat(line,S_ISDIR(mode)?"d":"-")
strcat(line,(mode&S_IRWXU)&S_IRUSR?"r":"-")
strcat(line,(mode&S_IRWXU)&S_IWUSR?"w":"-")
strcat(line,(mode&S_IRWXU)&S_IXUSR?"x":"-")
strcat(line,(mode&S_IRWXG)&S_IRGRP?"r":"-")
strcat(line,(mode&S_IRWXG)&S_IWGRP?"w":"-")
strcat(line,(mode&S_IRWXG)&S_IXGRP?"x":"-")
strcat(line,(mode&S_IRWXO)&S_IROTH?"r":"-")
strcat(line,(mode&S_IRWXO)&S_IWOTH?"w":"-")
strcat(line,(mode&S_IRWXO)&S_IXOTH?"x":"-")
return line
}
char *directory(char *argv)/*从程序参数取出目录*/
{
int i
for (i=strlen(argv)-1i--i)
if (argv[i]=='/'){
argv[i+1]='\0'
break
}
return argv
}
int main(int argc,char *argv[])
{
DIR *dirp
struct dirent *dirst
struct stat finfo
char *path,fname[512],mod[11],ctm[10]
struct passwd *user=NULL
struct tm *ltm
if (argc==1) path=directory(argv[0])
else path=argv[1]
dirp=opendir(path)
if (!dirp)
{
fprintf(stderr,"ERROR\n")
exit(-1)
}
for (dirst=readdir(dirp)dirstdirst=readdir(dirp))
{
strcpy(fname,path)
lstat(strcat(strcat(fname,"/"),dirst->d_name),&finfo)
user=getpwuid(finfo.st_uid)
printf("%s\t%10s\t",getmod(finfo.st_mode,mod),user->pw_name)
printf("%10d\t%9d\t",finfo.st_ino,finfo.st_size)
ltm=localtime(&finfo.st_mtime)
strftime(ctm,9,"%b",ltm)
printf("%5s",ctm)
strftime(ctm,9,"%d",ltm)
printf("%3s",ctm)
strftime(ctm,9,"%Y",ltm)
printf("%5s\t",ctm)
printf("%s\n",dirst->d_name)
}
closedir(dirp)
return 0
}
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)