| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990 |
- using log4net;
- using System;
- using System.IO;
- using System.Text;
- using System.Threading.Tasks;
- namespace DeviceCenter
- {
- class CarCamDevice : Device
- {
- public static readonly ILog log = LogManager.GetLogger("DeviceCenter");
- private int _userId;
- public int userId
- {
- get
- {
- return _userId;
- }
- }
- public CarCamDevice()
- {
- this.type = DeviceType.CAR_CAM;
- }
- public override async void Init()
- {
- status = DeviceStatus.CONNECTING;
- await Task.Run(() =>
- {
- _userId = CarCamSDK.Net_AddCamera(ip);
- int iRet1 = CarCamSDK.Net_ConnCamera(_userId, 30000, 10);
- if (iRet1 != 0)
- {
- CarCamSDK.Net_DelCamera(_userId);
- status = DeviceStatus.FAIL;
- message = "连接相机失败";
- }
- else
- {
- CarCamSDK.Net_RegOffLineClient(_userId);
- status = DeviceStatus.CONNECTED;
- }
- });
- }
- public override void dispose()
- {
- throw new NotImplementedException();
- }
- public int onGetCarPlate(int tHandle, uint uiImageId, ref CarCamSDK.T_ImageUserInfo2 tImageInfo, ref CarCamSDK.T_PicInfo tPicInfo)
- {
- string strTime = DateTime.Now.ToLocalTime().ToString("yyyy-MM-dd_HH_mm_ss_fff");
- log.Info("检测到车牌信息\n");
- //车辆图像
- if (tImageInfo.ucViolateCode == 0)
- {
- string szLprResult = Encoding.Default.GetString(tImageInfo.szLprResult).Replace("\0", "");
- log.Info("车牌:" + szLprResult);
- string strVehicleBrand = System.Text.Encoding.Default.GetString(tImageInfo.strVehicleBrand).Replace("\0", "");
- log.Info("车型:" + strVehicleBrand);
- string vehicleType = VehicleUtil.getVehicleType(tImageInfo.ucVehicleSize);//车辆类型
- log.Info("车辆类型:" + vehicleType);
- string vehicleColor = VehicleUtil.getColor(tImageInfo.ucPlateColor);//车牌颜色
- log.Info("颜色:" + vehicleColor);
- string path = AppDomain.CurrentDomain.BaseDirectory + "image";
- if (!Directory.Exists(path))
- {
- Directory.CreateDirectory(path);
- }
- string strImageFile1 = VehicleUtil.savePanoramaPic(path, ref tPicInfo, 1);
- string strImageFile2 = VehicleUtil.savePanoramaPic(path, ref tPicInfo, 2); ;
- }
- return 0;
- }
- }
- }
|