fuliqi
2024-08-29 4163c93761115c7524ef74a557a1f5e01eafb429
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
package com.ycl.api.YS.liveview.live;
 
import com.ycl.api.YS.NetDemo;
import com.ycl.api.YS.util.Common;
 
import javax.swing.*;
import java.io.File;
 
/**
 * 
 * @introduction Live view snapshot
 * @description Support IPC/NVR/VMS
 */
public class Capture {
    
    /**
     * 
     * @introduction Live view snapshot
     * @description Calling the interface of NETDEV_CapturePicture
     *
     */
    public static void CapturePicture() {
           if(null == NetDemo.lpUserID) {
                JOptionPane.showMessageDialog(null, "Please Login device first. error code"+NetDemo.netdevsdk.NETDEV_GetLastError());
                return;
                }
           String strSeparator = File.separator;
           String strPicPath = System.getProperty("user.dir").replaceAll("%20"," ") +strSeparator+ "Pic" + strSeparator + Common.timeStamp() + "_D"+NetDemo.ChannelID;
           if(null != NetDemo.lpPlayHandle){
               boolean bRet = NetDemo.netdevsdk.NETDEV_CapturePicture(NetDemo.lpPlayHandle, strPicPath, 1);
               if(bRet){
                   JOptionPane.showMessageDialog(null, "Success! The Path: " + strPicPath);
                   return;
                   }
               }
           if(null != NetDemo.lpUserID){
                if(NetDemo.ChannelID == 0){
                    JOptionPane.showMessageDialog(null, "Please select the channel first.");
                    return;
                }
                boolean bRet = NetDemo.netdevsdk.NETDEV_CaptureNoPreview(NetDemo.lpUserID, NetDemo.ChannelID, 0, strPicPath, 1);
                if(bRet){
                    JOptionPane.showMessageDialog(null, "Non-preview capture success! Path: " + strPicPath);
                }else {
                    JOptionPane.showMessageDialog(null, "Make sure the device supports non-preview capture.");
                }
            }
    }
}