首页 > 编程知识 正文

python opencv读取图像,opencv摄像头图像采集

时间:2023-05-05 10:26:32 阅读:167274 作者:2117

1、项目需要存储16位深度的png图像时,加速算法以缩短时间,为将数据从文本文档转换为png占用较小的闪存,一举获益良多;

iplimage * ca image=cvcreateimage (cv size (w,h ),IPL_DEPTH_16U,3 );

cv : mat src=cvarrtomat (ca image );

cv:Mat dst;

SRC.convertto(dst,CV_16UC3);

STD :3360 vectorintcompression _ params;

compression _ params.push _ back (cv :3360 im write _ png _ compression;

compression_Params.push_back(0;

compression _ params.push _ back (cv :3360 im write _ png _ strategy;

compression _ params.push _ back (cv :3360 im write _ png _ strategy _ default );

char name[128]={ 0 };

string ss='res ';

sprintf(name,' result_images(%s.png ),ss.c_str ) );

IMwrite(name,dst,compression_params );

2、IplImage和Mat的相互转换也记录在这里

a. Mat --IplImage

matmat_img=imread(samples.BMP );

IplImage* ipl_img;

IPL_img=iplimage(mat_img;

b. IplImage---Mat

iplimage * IPL _ img=cv loadimage (samples.BMP );

Mat mat_img;

mat_img=mat(IPL_img; //mat(constiplimage*img,bool copyData=false ); //opencv2.0

//mat_img=Cvarrtomat(IPL_img ); //opencv3.0

3、高速get到Mat所在位置的像素值

matsrc=imread(test.jpg );

int x=src.cols-10;

int y=src.rows-20;

matp=mat.col(x ).row ) y;

uchar* ptr=(uchar* ) p.data;

int B=ptr[0];

int G=ptr[1];

int R=ptr[2];

cout'res:'B' 'G' 'R' 'endl;

版权声明:该文观点仅代表作者本人。处理文章:请发送邮件至 三1五14八八95#扣扣.com 举报,一经查实,本站将立刻删除。