远程闭路中demodemo是什么意思思

11防损手册 (DEMO)_百度文库
两大类热门资源免费畅读
续费一年阅读会员,立省24元!
11防损手册 (DEMO)
&&超市资料大全
阅读已结束,下载文档到电脑
想免费下载本文?
定制HR最喜欢的简历
下载文档到电脑,方便使用
还剩60页未读,继续阅读
定制HR最喜欢的简历
你可能喜欢海康威视远程监控-Android端Demo - CSDN博客
海康威视远程监控-Android端Demo

更新一个抓图功能代码见最底部
目前海康威视官网上并没有提供Android的API和SKD所以下面的SDK是反编译后得到的。
效果图“现在”截不了,不是我不给图。公司上面有人在调试硬件设备
1.先了解下大概的&&部署图&&都属于(直连的性质):
& && && && && && &&&自己随便画的有点丑。。。别喷
2.也可以部署某个服务器到互联网上、使用手持设备(android)通过联网直接远程控制摄像头等等是可行的、这就看亲们自己的想想力了。
3.此文用于交流不涉及商业信息、如有雷同不胜荣幸。
4.现在Demo已经实现的功能:
& && & 4.1.简单的八个方向控制
5.正在完善的功能:
& && & 5.1.抓图、录像、远程关机重启、多屏展示等等后续有完善的功能继续更新
下面咱们开始看代码:
1、MonitorCameraInfo.java(监控点信息类)
2、SjrsSurfaceView.java(继承自SurfaceView,用来播放视频并显示)
3、VideoShowActivity(主activity)
4、清单文件中一定要加上网络访问的权限 android.permission.INTERNET
5、获取视频展示有两种,一种是文件模式,一种是流模式(我用的是流模式)
6、下面是工程结构图,需要完整的可以下Demo研究,咱们可以互相交流
按照官网提供的调用顺序如下:
配置好登陆需要的相关信息:
public class VideoShowActivity extends Activity {& && &&&/** SurfaceView对象,用来显示视频 */& && &&&private SjrsSurfaceView nowSjrsSurfaceV& && &&&/** 视频向上 */& && &&&private Button btUp;& && &&&/** 视频向下 */& && &&&private Button btD& && &&&/** 视频向左 */& && &&&private Button btL& && &&&/** 视频向右 */& && &&&private Button btR& && &&&/** 视频上左 */& && &&&private Button btUpL& && &&&/** 视频上右 */& && &&&private Button btUpR& && &&&/** 视频下左 */& && &&&private Button btDownL& && &&&/** 视频下右 */& && &&&private Button btDownR& && &&&/** button点击事件*/& && &&&private ButtonListener btnL& && &&&/**& && &&&实例化网络库SDK*/& && &&&private SjrsSurfaceView mS& && &&&/** 监控点信息类 */& && &&&private MonitorCameraInfo cameraI& && &&&protected void onCreate(Bundle savedInstanceState) {& && && && && & super.onCreate(savedInstanceState);& && && && && & setContentView(R.layout.activity_main);& && && && && & findView();& && && && && & setListener();& && && && && & init();& && &&&}
& && &&&/**& && && &* 组件配置& && && &*/& && &&&private void findView() {& && && && && & // TODO Auto-generated method stub& && && && && & nowSjrsSurfaceView = (SjrsSurfaceView) findViewById(R.id.video);& && && && && & btUp = (Button) findViewById(R.id.bt_up);& && && && && & btDown = (Button) findViewById(R.id.bt_down);& && && && && & btLeft = (Button) findViewById(R.id.bt_left);& && && && && & btRigth = (Button) findViewById(R.id.bt_rigth);& && && && && & btUpLeft = (Button) findViewById(R.id.bt_up_left);& && && && && & btUpRigth = (Button) findViewById(R.id.bt_up_rigth);& && && && && & btDownLeft = (Button) findViewById(R.id.bt_down_left);& && && && && & btDownRigth = (Button) findViewById(R.id.bt_down_rigth);& && && && && & btnListener = new ButtonListener();& && &&&}
& && &&&/**& && && &* 监听设置& && && &*/& && &&&private void setListener() {& && && && && & // TODO Auto-generated method stub& && && && && & btUp.setOnClickListener(btnListener);& && && && && & btDown.setOnClickListener(btnListener);& && && && && & btLeft.setOnClickListener(btnListener);& && && && && & btRigth.setOnClickListener(btnListener);& && && && && & btUp.setOnTouchListener(btnListener);& && && && && & btDown.setOnTouchListener(btnListener);& && && && && & btLeft.setOnTouchListener(btnListener);& && && && && & btRigth.setOnTouchListener(btnListener);& && && && && & btUpLeft.setOnClickListener(btnListener);& && && && && & btUpRigth.setOnClickListener(btnListener);& && && && && & btDownLeft.setOnClickListener(btnListener);& && && && && & btDownRigth.setOnClickListener(btnListener);& && && && && & btUpLeft.setOnTouchListener(btnListener);& && && && && & btUpRigth.setOnTouchListener(btnListener);& && && && && & btDownLeft.setOnTouchListener(btnListener);& && && && && & btDownRigth.setOnTouchListener(btnListener);& && &&&}
& && &&&/**& && && &* 页面初始化& && && &*/& && &&&private void init() {& && && && && & // TODO Auto-generated method stub& && && && && & mSurface = new SjrsSurfaceView(VideoShowActivity.this);& && &&&}
& && &&&/**& && && &* 显示& && && &*/& && &&&protected void onResume() {& && && && && & super.onResume();& && && && && & // 如果没有在播放的话& && && && && & if (!nowSjrsSurfaceView.playFlag) {& && && && && && && && &// 监控点信息类& && && && && && && && &cameraInfo = new MonitorCameraInfo();& && && && && && && && &//224.186.114.116& && && && && && && && &cameraInfo.serverip = &192.168.1.206&;& && && && && && && && &cameraInfo.serverport = 8000;& && && && && && && && &cameraInfo.username = &admin&;& && && && && && && && &cameraInfo.userpwd = &12345&;& && && && && && && && &cameraInfo.channel = 2;& && && && && && && && &cameraInfo.describe = &测试点&;
& && && && && && && && &nowSjrsSurfaceView.setMonitorInfo(cameraInfo);& && && && && && && && &// 开始实时预览& && && && && && && && &nowSjrsSurfaceView.startPlay();& && && && && & }& && &&&}
& && &&&/**& && && &* 暂停& && && &*/& && &&&protected void onPause() {& && && && && & super.onPause();& && && && && & if (nowSjrsSurfaceView.playFlag) {& && && && && && && && &nowSjrsSurfaceView.stopPlay(); // 停止实时预览& && && && && & }& && &&&}
& && &&&/**& && && &* 方向按键监听& && && &* 注意:此处的通道号参数 实质为:2 但必须指定为:1(主通道)才可以做控制& && && &*/& && &&&public class ButtonListener implements OnTouchListener,OnClickListener {
& && && && && & @Override& && && && && & public boolean onTouch(View v, MotionEvent event) {& && && && && && && && &switch (v.getId()) {& && && && && && && && &case R.id.bt_up:& && && && && && && && && && &&&mSurface.SjrsSurface().NET_DVR_PTZControl_Other(cameraInfo.userId,1,21,0);& && && && && && && && && && &&&System.out.println(&向上&);& && && && && && && && && && &&&& && && && && && && && &case R.id.bt_down:& && && && && && && && && && &&&mSurface.SjrsSurface().NET_DVR_PTZControl_Other(cameraInfo.userId,1,22,0);& && && && && && && && && && &&&System.out.println(&向下&);& && && && && && && && && && &&&& && && && && && && && &case R.id.bt_left:& && && && && && && && && && &&&mSurface.SjrsSurface().NET_DVR_PTZControl_Other(cameraInfo.userId,1,23,0);& && && && && && && && && && &&&System.out.println(&向左&);& && && && && && && && && && &&&& && && && && && && && &case R.id.bt_rigth:& && && && && && && && && && &&&mSurface.SjrsSurface().NET_DVR_PTZControl_Other(cameraInfo.userId,1,24,0);& && && && && && && && && && &&&System.out.println(&向右&);& && && && && && && && && && &&&& && && && && && && && &case R.id.bt_up_left:& && && && && && && && && && &&&mSurface.SjrsSurface().NET_DVR_PTZControl_Other(cameraInfo.userId,1,25,0);& && && && && && && && && && &&&System.out.println(&上左&);& && && && && && && && && && &&&& && && && && && && && &case R.id.bt_up_rigth:& && && && && && && && && && &&&mSurface.SjrsSurface().NET_DVR_PTZControl_Other(cameraInfo.userId,1,26,0);& && && && && && && && && && &&&System.out.println(&上右&);& && && && && && && && && && &&&& && && && && && && && &case R.id.bt_down_left:& && && && && && && && && && &&&mSurface.SjrsSurface().NET_DVR_PTZControl_Other(cameraInfo.userId,1,27,0);& && && && && && && && && && &&&System.out.println(&下左&);& && && && && && && && && && &&&& && && && && && && && &case R.id.bt_down_rigth:& && && && && && && && && && &&&mSurface.SjrsSurface().NET_DVR_PTZControl_Other(cameraInfo.userId,1,28,0);& && && && && && && && && && &&&System.out.println(&下右&);& && && && && && && && && && &&&& && && && && && && && &/*case R.id.bt_amplification:& && && && && && && && && && &&&boolean iss = mSurface.SjrsSurface().NET_DVR_PTZControlWithSpeed(cameraInfo.playNum,15,0,3);& && && && && && && && && && &&&System.out.println(&异常:&+mSurface.SjrsSurface().NET_DVR_GetLastError());& && && && && && && && && && &&&System.out.println(&焦距放大&+iss);& && && && && && && && && && &&&& && && && && && && && &case R.id.bt_shrink:& && && && && && && && && && &&&boolean is = mSurface.SjrsSurface().NET_DVR_PTZControlWithSpeed(cameraInfo.playNum,16,0,3);& && && && && && && && && && &&&System.out.println(&焦距缩小&+is);& && && && && && && && && && &&&*/& && && && && && && && &default:& && && && && && && && && && &&&& && && && && && && && &}& && && && && && && && && && && && && & }& && && && && & @Override& && && && && & public void onClick(View v) {& && && && && && && && &switch (v.getId()) {& && && && && && && && &case R.id.bt_up:& && && && && && && && && && &&&mSurface.SjrsSurface().NET_DVR_PTZControl_Other(cameraInfo.userId,1,21,1);& && && && && && && && && && &&&System.out.println(&结束向上移动&);& && && && && && && && && && &&&& && && && && && && && &case R.id.bt_down:& && && && && && && && && && &&&mSurface.SjrsSurface().NET_DVR_PTZControl_Other(cameraInfo.userId,1,22,1);& && && && && && && && && && &&&System.out.println(&结束向下移动&);& && && && && && && && && && &&&& && && && && && && && &case R.id.bt_left:& && && && && && && && && && &&&mSurface.SjrsSurface().NET_DVR_PTZControl_Other(cameraInfo.userId,1,23,1);& && && && && && && && && && &&&System.out.println(&结束向左移动&);& && && && && && && && && && &&&& && && && && && && && &case R.id.bt_rigth:& && && && && && && && && && &&&mSurface.SjrsSurface().NET_DVR_PTZControl_Other(cameraInfo.userId,1,24,1);& && && && && && && && && && &&&System.out.println(&结束向右移动&);& && && && && && && && && && &&&& && && && && && && && &case R.id.bt_up_left:& && && && && && && && && && &&&mSurface.SjrsSurface().NET_DVR_PTZControl_Other(cameraInfo.userId,1,25,1);& && && && && && && && && && &&&System.out.println(&结束上左移动&);& && && && && && && && && && &&&& && && && && && && && &case R.id.bt_up_rigth:& && && && && && && && && && &&&mSurface.SjrsSurface().NET_DVR_PTZControl_Other(cameraInfo.userId,1,26,1);& && && && && && && && && && &&&System.out.println(&结束上右移动&);& && && && && && && && && && &&&& && && && && && && && &case R.id.bt_down_left:& && && && && && && && && && &&&mSurface.SjrsSurface().NET_DVR_PTZControl_Other(cameraInfo.userId,1,27,1);& && && && && && && && && && &&&System.out.println(&结束下左移动&);& && && && && && && && && && &&&& && && && && && && && &case R.id.bt_down_rigth:& && && && && && && && && && &&&mSurface.SjrsSurface().NET_DVR_PTZControl_Other(cameraInfo.userId,1,28,1);& && && && && && && && && && &&&System.out.println(&结束下右移动&);& && && && && && && && && && &&&& && && && && && && && &/*case R.id.bt_amplification:& && && && && && && && && && &&&mSurface.SjrsSurface().NET_DVR_PTZControl_Other(0,1,13,1);& && && && && && && && && && &&&System.out.println(&结束焦距放大&);& && && && && && && && && && &&&& && && && && && && && &case R.id.bt_shrink:& && && && && && && && && && &&&mSurface.SjrsSurface().NET_DVR_PTZControl_Other(0,1,14,1);& && && && && && && && && && &&&System.out.println(&结束焦距缩小&);& && && && && && && && && && &&&*/& && && && && && && && &default:& && && && && && && && && && &&&& && && && && && && && &}& && && && && & }& && &&&}}
public class MonitorCameraInfo {& && &&&public String serverip = &&;& && &&&public int serverport = 0;& && &&&public String username = &&;& && &&&public String userpwd = &&;& && &&&public int channel = 0;& && &&&public String describe = &&;& && &&&/**登录帐号id */& && &&&public int userId = 0;& && &&&/**播放返回值 */& && &&&public int playNum = 0;& && &&&/**抓图存放路劲 */& && &&&public String filepath = getSDRootPath()+&/HCNetSDK&;& && &&&public MonitorCameraInfo() {}
初始化SDK登陆&&播放画面:
package com.HCNetSDK.P
/*** SurfaceView,用来播放视频并显示* 在要显示视频的SurfaceView对象创建完成后(即surfaceCreated()方法被触发)再连接服务器* 进行实时预览,否则在实时预览时可能会出现SurfaceView尚未完全加载成功,导致调调数据显示异常*/public class SjrsSurfaceView extends SurfaceView implements SurfaceHolder.Callback {& && &&&private HCNetSDK videoC& & //网络库sdk& && &&&private Player myPlayer =&&//播放库sdk& && &&&public int playPort = -1;& &//播放端口& && &&&public boolean playFlag =& &//播放标志& && &&&public MonitorCameraInfo cameraInfo =& &//监控点信息
& && &&&private SurfaceHolder holder =
& && &&&public SjrsSurfaceView(Context paramContext) {& && && && && & super(paramContext);& && && && && & initSurfaceView();& && &&&}
& && &&&public SjrsSurfaceView(Context paramContext,& && && && && && && && &AttributeSet paramAttributeSet) {& && && && && & super(paramContext, paramAttributeSet);& && && && && & initSurfaceView();& && &&&}
& && &&&public SjrsSurfaceView(Context paramContext,& && && && && && && && &AttributeSet paramAttributeSet, int paramInt) {& && && && && & super(paramContext, paramAttributeSet);& && && && && & initSurfaceView();& && &&&}
& && &&&private void initSurfaceView() {& && && && && & getHolder().addCallback(this);& && &&&}
& && &&&public HCNetSDK SjrsSurface(){& && && && && & //实例化海康威视android sdk& && && && && & if(videoCtr == null){& && && && && && && && &videoCtr = new HCNetSDK();& && && && && & }& && && && && & return videoC& && &&&}& && &&&public boolean onDown(MotionEvent paramMotionEvent) {& && && && && && && &&&}
& && &&&public boolean onFling(MotionEvent paramMotionEvent1,& && && && && && && && &MotionEvent paramMotionEvent2, float paramFloat1, float paramFloat2) {& && && && && && && &&&}
& && &&&public void onLongPress(MotionEvent paramMotionEvent) {& && &&&}
& && &&&public boolean onScroll(MotionEvent paramMotionEvent1,& && && && && && && && &MotionEvent paramMotionEvent2, float paramFloat1, float paramFloat2) {& && && && && && && &&&}
& && &&&public void onShowPress(MotionEvent paramMotionEvent) {& && &&&}
& && &&&public boolean onSingleTapUp(MotionEvent paramMotionEvent) {& && && && && && && &&&}
& && &&&public void surfaceChanged(SurfaceHolder paramSurfaceHolder, int paramInt1,& && && && && && && && &int paramInt2, int paramInt3) {& && &&&}
& && &&&public void surfaceCreated(SurfaceHolder paramSurfaceHolder) {& && && && && & holder = this.getHolder();& && &&&}
& && &&&public void surfaceDestroyed(SurfaceHolder paramSurfaceHolder) {}
& && &&&public void setMonitorInfo(MonitorCameraInfo setMonitorInfo) {& && && && && & this.cameraInfo = setMonitorI& && &&&}
& && &&&/**& && && &* flag 1/暂停 0/恢复& && && &*/& && &&&public void pausePaly(int flag) {& && && && && & myPlayer.pause(playPort, flag);& && &&&}
& && &&&/**& && && &* 停止播放&释放资源& && && &*/& && &&&public void stopPlay() {& && && && && & try {& && && && && && && && &playFlag =& && && && && && && && &videoCtr.NET_DVR_StopRealPlay(playPort);& && && && && && && && &videoCtr.NET_DVR_Logout_V30(cameraInfo.userId);& && && && && && && && &cameraInfo.userId = -1;& && && && && && && && &videoCtr.NET_DVR_Cleanup();
& && && && && && && && &//停止播放后释放资源& && && && && && && && &if (myPlayer != null) {& && && && && && && && && && &&&myPlayer.stop(playPort);& && && && && && && && && && &&&myPlayer.closeStream(playPort);& && && && && && && && && && &&&myPlayer.freePort(playPort);& && && && && && && && && && &&&playPort = -1;& && && && && && && && && && &&&//使用绘图缓存后释放资源& && && && && && && && && && &&&destroyDrawingCache();& && && && && && && && &}& && && && && & } catch (Exception e) {& && && && && && && && &e.printStackTrace();& && && && && & } finally {& && && && && && && && &//暂不做任何操作& && && && && & }& && &&&}
& && &&&/**& && && &*& && &&&开始实时预览& && && &**/& && &&&public void startPlay() {& && && && && & try {& && && && && && && && &//实例化播放API& && && && && && && && &myPlayer = Player.getInstance();& && && && && && && && &SjrsSurface();& && && && && && && && &//初始化海康威视android sdk& && && && && && && && &videoCtr.NET_DVR_Init();& && && && && && && && &//设置错误回掉函数& && && && && && && && &videoCtr.NET_DVR_SetExceptionCallBack(mExceptionCallBack);& && && && && && && && &//设置连接超时时长& && && && && && && && &videoCtr.NET_DVR_SetConnectTime(60000);& && && && && && && && &//获取空闲播放端口& && && && && && && && &playPort = myPlayer.getPort();& && && && && && && && &NET_DVR_DEVICEINFO_V30 deviceInfo = new NET_DVR_DEVICEINFO_V30();& && && && && && && && &//登录服务器& && && && && && && && &cameraInfo.userId = videoCtr.NET_DVR_Login_V30(cameraInfo.serverip,& && && && && && && && && && && && && & cameraInfo.serverport, cameraInfo.username,& && && && && && && && && && && && && & cameraInfo.userpwd, deviceInfo);
& && && && && && && && &System.out.println(&下面是设备信息************************&);& && && && && && && && &System.out.println(&userId=& + cameraInfo.userId);& && && && && && && && &System.out.println(&通道开始=& + deviceInfo.byStartChan);& && && && && && && && &System.out.println(&通道个数=& + deviceInfo.byChanNum);& && && && && && && && &System.out.println(&设备类型=& + deviceInfo.byDVRType);& && && && && && && && &System.out.println(&ip通道个数=& + deviceInfo.byIPChanNum);
& && && && && && && && &byte[] sbbyte = deviceInfo.sSerialN& && && && && && && && &String sNo = &&;& && && && && && && && &for (int i = 0; i & sbbyte. i++) {& && && && && && && && && && &&&sNo += String.valueOf(sbbyte);& && && && && && && && &}
& && && && && && && && &System.out.println(&设备序列号=& + sNo);& && && && && && && && &System.out.println(&************************&);
& && && && && && && && &// 参数结构体& && && && && && && && &NET_DVR_CLIENTINFO clientInfo = new NET_DVR_CLIENTINFO();& && && && && && && && &// 浏览通道号& && && && && && && && &clientInfo.lChannel = cameraInfo.& && && && && && && && &// 子码流(保证图像连续性)tcp连接方式,如果要保证图像清晰度,可选用主码流 & && && && && && && && &clientInfo.lLinkMode = 0x; & && && && && && && && &// 多播地址 需要多播时配置& && && && && && && && &clientInfo.sMultiCastIP =& && && && && && && && &// 启动实时预览& && &&&mRealDataCallback即为数据回传回掉函数
& && && && && && && && &cameraInfo.playNum = videoCtr.NET_DVR_RealPlay_V30(cameraInfo.userId, clientInfo,mRealPlayCallBack, false);& && && && && && && && &System.out.println(&playFlags=& + cameraInfo.playNum);& && && && && && && && &System.out.println(&GetLastError=&+ videoCtr.NET_DVR_GetLastError());
& && && && && & } catch (Exception e) {& && && && && && && && &e.printStackTrace();& && && && && && && && &// 释放资源& && && && && && && && &stopPlay();& && && && && & }& && &&&}
& && &&&/**& && && &* 异常回掉函数& && && &*/& && &&&private ExceptionCallBack mExceptionCallBack = new ExceptionCallBack() {
& && && && && & public void fExceptionCallBack(int arg0, int arg1, int arg2) {& && && && && && && && &// TODO Auto-generated method stub& && && && && && && && &System.out.println(&异常回掉函数运行!&);& && && && && & }& && &&&};
& && &&&private RealPlayCallBack mRealPlayCallBack = new RealPlayCallBack() {& && && && && & @Override& && && && && & public void fRealDataCallBack(int lRealHandle, int dataType,& && && && && && && && && && &&&byte[] paramArrayOfByte, int byteLen) {& && && && && && && && &//端口连接状态返回码& && && && && && && && &if (playPort == -1)& && && && && && && && && && &&&& && && && && && && && &// dataType视频连接数量& && &&&1个或者4个& && && && && && && && &switch (dataType) {& && && && && && && && &case 1: & && && && && && && && && && &&&// 打开流连接& && && && && && && && && && &&&if (myPlayer.openStream(playPort, paramArrayOfByte, byteLen,1024 * 1024)) {& && && && && && && && && && && && && & // 1.连接状态& && &&&2.视频模式:1为实时& && && && && && && && && && && && && & if (myPlayer.setStreamOpenMode(playPort, 1)) {& && && && && && && && && && && && && && && && &// 放入要播放的控件中& && &&&& && && && && && && && && && && && && && && && &if (myPlayer.play(playPort, holder)) {& && && && && && && && && && && && && && && && && && &&&playFlag =& && && && && && && && && && && && && && && && &} else {& && && && && && && && && && && && && && && && && && &&&playError(3);& && && && && && && && && && && && && && && && &}& && && && && && && && && && && && && & } else {& && && && && && && && && && && && && && && && &playError(2);& && && && && && && && && && && && && & }& && && && && && && && && && &&&} else {& && && && && && && && && && && && && & playError(1);& && && && && && && && && && &&&}& && && && && && && && && && &&&& && && && && && && && &case 4:& && && && && && && && && && &&&if (playFlag && myPlayer.inputData(playPort, paramArrayOfByte,byteLen)) {& && && && && && && && && && && && && & playFlag =& && && && && && && && && && &&&} else {& && && && && && && && && && && && && & playError(4);& && && && && && && && && && && && && & playFlag =& && && && && && && && && && &&&}& && && && && && && && &}& && && && && & }& && &&&};
& && &&&/**& && && &* 打印出相对应的异常& && && &* @param step& && && &*/& && &&&private void playError(int step) {
& && && && && & switch (step) {& && && && && & case 1:& && && && && && && && &System.out.println(&openStream error,step=& + step);& && && && && && && && && && && && && & case 2:& && && && && && && && &System.out.println(&setStreamOpenMode error,step=& + step);& && && && && && && && && && && && && & case 3:& && && && && && && && &System.out.println(&play error,step=& + step);& && && && && && && && && && && && && & case 4:& && && && && && && && &System.out.println(&inputData error,step=& + step);& && && && && && && && && && && && && & }& && && && && & stopPlay();& && &&&}}
最近有些忙就弄了一个“抓图”功能,勿喷勿喷
这个代码& &你可以自己弄个按钮来触发,不多说了
& & NET_DVR_JPEGPARA jpeg = new NET_DVR_JPEGPARA();
& && && && && & INT_PTR a = new INT_PTR();
& && && && && & System.out.println(&返回长度:& + a);
& && && && && & /* a.iValue = 1024; */
& && && && && & byte[] num = new byte[1024 * 1024];
& && && && && & // 设置图片的分辨率
& && && && && & jpeg.wPicSize = 2;
& && && && && & // 设置图片质量
& && && && && & jpeg.wPicQuality = 2;
& && && && && & // 创建文件目录
& && && && && & File file = new File(cameraInfo.filepath + &/a.jpg&);
& && && && && & /* file.mkdirs(); */
& && && && && & // System.out.println(&文件路劲:&+cameraInfo.filepath);
& && && && && & /** 1.userId 返回值 2.通道号 3.图像参数 4.路劲 */
& && && && && & boolean is = mSurface.SjrsSurface()
& && && && && && && && &.NET_DVR_CaptureJPEGPicture_NEW(cameraInfo.userId,
& && && && && && && && && && &&&cameraInfo.channel, jpeg, num, 1024 * 1024, a);
& && && && && & System.out.println(is + &&&&
& && && && && && && && &+ mSurface.SjrsSurface().NET_DVR_GetLastError());
& && && && && & // 存储本地
& && && && && & BufferedOutputStream outputStream =
& && && && && & try {
& && && && && && &&&outputStream = new BufferedOutputStream(
& && && && && && && && && & new FileOutputStream(file));
& && && && && && &&&outputStream.write(num);
& && && && && && &&&outputStream.flush();
& && && && && & } catch (Exception e) {
& && && && && && &&&// TODO: handle exception
& && && && && && &&&e.printStackTrace();
& && && && && & } finally {
& && && && && && &&&if (outputStream != null) {
& && && && && && && && &try {
& && && && && && && && && & outputStream.close();
& && && && && && && && &} catch (IOException e) {
& && && && && && && && && & // TODO Auto-generated catch block
& && && && && && && && && & e.printStackTrace();
& && && && && && && && &}
& && && && && && &&&}
& && && && && & }
& && && && && & Toast.makeText(VideoShowActivity.this, &截取成功,保存在SDK的& + cameraInfo.filepath + &下&, 1).show();
注意加权限:android.permission.INTERNET
&&果断上源码Demo~~~亲你邪恶了。。
& & *& &&&其他功能&&抓图、录像、远程关机重启、多屏展示等等(功能很多很多。。。)后续有完善的功能继续更新
本文已收录于以下专栏:
相关文章推荐
在接触海康之前有接触过大华视频的集成,萤石视频的集成,现在海康8800的视频是第一次集成,其中遇到了一个坑还是值得说一下的(个人认为还是很坑的)。
下载地址:海康8800所需jar 和so文件
海康威视的网络摄像头使用:
开发工具:vs2013
海康SDK下载海康威视SDK:网址:/cn/download_61.html
OpenCV+海康威视摄像头的实时读取环境
PC:i7-4970 16GB内存
摄像头型号:DS-2CD3310D-I(2.8mm)
windows-x64、vs2012、op...
他的最新文章
讲师:王禹华
讲师:宋宝华
您举报文章:
举报原因:
原文地址:
原因补充:
(最多只允许输入30个字)

我要回帖

更多关于 demo是什么意思 的文章

 

随机推荐