海康摄像头的调试
在海康官网 下载 ivms-4200 客户端,并且 摄像头和电脑在一个网段内,
客户端会自动搜索 网段内的 摄像头。
-------------------------------------------------------------------------------------------------------------------------------
海康sdk 下载地址
应该下载 设备网络SDK_Linux32 和 播放库SDK_Windows
登陆设备的方法
/**
* @return login ID
* @fn loginNormalDevice
* @author lsw8569013
* @brief login on device
*/
private int loginNormalDevice() {
// get instance
m_oNetDvrDeviceInfoV30 = new NET_DVR_DEVICEINFO_V30();
if (null == m_oNetDvrDeviceInfoV30) {
Log.e(TAG, "HKNetDvrDeviceInfoV30 new is failed!");
return -1;
}
// call NET_DVR_Login_v30 to login on, port 8000 as default
int iLogID = HCNetSDK.getInstance().NET_DVR_Login_V30(ADDRESS, PORT,
USER, PSD, m_oNetDvrDeviceInfoV30);
if (iLogID < 0) {
Log.e(TAG, "NET_DVR_Login is failed!Err:"
+ HCNetSDK.getInstance().NET_DVR_GetLastError());
return -1;
}
if (m_oNetDvrDeviceInfoV30.byChanNum > 0) {
m_iStartChan = m_oNetDvrDeviceInfoV30.byStartChan;
m_iChanNum = m_oNetDvrDeviceInfoV30.byChanNum;
} else if (m_oNetDvrDeviceInfoV30.byIPChanNum > 0) {
m_iStartChan = m_oNetDvrDeviceInfoV30.byStartDChan;
m_iChanNum = m_oNetDvrDeviceInfoV30.byIPChanNum
+ m_oNetDvrDeviceInfoV30.byHighDChanNum * 256;
}
Log.e(TAG, "NET_DVR_Login is Successful!");
return iLogID;
}
截图的方法
/**
* 摄像头抓图
* @param view
*/
public void getPIC(View view) {
String path = Environment.getExternalStorageDirectory()+"/抓图.jpg";
NET_DVR_JPEGPARA jpegpara = new NET_DVR_JPEGPARA();
jpegpara.wPicSize = 2;
jpegpara.wPicQuality = 2;
HCNetSDK NetSdk = HCNetSDK.getInstance();
boolean b = NetSdk.NET_DVR_CaptureJPEGPicture(m_iLogID, 1, jpegpara, path);
if(b){
LogUtil.e("抓图成功");
ImageView iv_showCAMERAPic = findViewById(R.id.iv_showCAMERAPic);
iv_showCAMERAPic.setImageBitmap(BitmapFactory.decodeFile(path));
}else{
LogUtil.e("抓图error"+NetSdk.NET_DVR_GetLastError() ) ;
}
}