python调用海康摄像头_Windows下Python调用海康SDK实时显示网络摄像头

这篇博客介绍了如何在Windows环境下使用Python调用海康摄像头的SDK,实现实时显示网络摄像头的YUV数据。通过解码回调函数DecCBFun处理YV12格式的视频数据,将YUV转换为RGB图像并显示。代码中包含了初始化、预览、数据处理和释放资源的完整流程。
摘要由CSDN通过智能技术生成

//int colhalf=col>>1;

tmp = (row / 2)*(width / 2) + (col / 2);

// if((row==1)&&( col>=1400 &&col<=1600))

// {

// printf("col=%d,row=%d,width=%d,tmp=%d.\n",col,row,width,tmp);

// printf("row*width+col=%d,width*height+width*height/4+tmp=%d,width*height+tmp=%d.\n",row*width+col,width*height+width*height/4+tmp,width*height+tmp);

// }

Y = (unsigned int)inYv12[row*width + col];

U = (unsigned int)inYv12[width*height + width*height / 4 + tmp];

V = (unsigned int)inYv12[width*height + tmp];

// if ((col==200))

// {

// printf("col=%d,row=%d,width=%d,tmp=%d.\n",col,row,width,tmp);

// printf("width*height+width*height/4+tmp=%d.\n",width*height+width*height/4+tmp);

// return ;

// }

if ((idx + col * 3 + 2)> (1200 * widthStep))

{

//printf("row * widthStep=%d,idx+col*3+2=%d.\n",1200 * widthStep,idx+col*3+2);

}

outYuv[idx + col * 3] = Y;

outYuv[idx + col * 3 + 1] = U;

outYuv[idx + col * 3 + 2] = V;

}

}

//printf("col=%d,row=%d.\n",col,row);

}

//解码回调 视频为YUV数据(YV12),音频为PCM数据

void CALLBACK DecCBFun(long nPort, char * pBuf, long nSize, FRAME_INFO * pFrameInfo, long nReserved1, long nReserved2)

{

long lFrameType = pFrameInfo->nType;

if (lFrameType == T_

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值