public void OnRecvFrame(IntPtr pDevice, IntPtr pImageBuffer, ref DeviceFrameInfo pFrInfo, IntPtr lParam) { IntPtr pRGB24Buff = CGAPI.DeviceISP(mDeviceHandle, pImageBuffer, ref pFrInfo); if (pRGB24Buff == IntPtr.Zero) { return; } //CGAPI.DeviceDisplayRGB24(mDeviceHandle, pRGB24Buff, ref pFrInfo); //显示图像有关. //Debug.Log("OnRecvFrame..."); //重点->这里是将IntPtr转换为byte[]数组. int countBuf = (int)(pFrInfo.uiWidth * pFrInfo.uiHeight); //mBufHandle = new byte[countBuf]; Marshal.Copy(pImageBuffer, mBufHandle, 0, countBuf); for (int i = 0; i < mBufHandle.Length; i++) { if (mBufHandle[i] == 0) { continue; } else { //Debug.Log("i " + i + ", val " + mBufHandle[i]); } } DateTime startTime = TimeZone.CurrentTimeZone.ToLocalTime(new System.DateTime(1970, 1, 1, 0, 0, 0, 0)); DateTime nowTime = DateTime.Now; long unixTime = (long)Math.Round((nowTime - startTime).TotalMilliseconds, MidpointRounding.AwayFromZero); if (IsShowCGCamFrame) { if (LastTimeVal == 0) { LastTimeVal = unixTime; } else { CGCamFrameCount++; long dTimeVal = unixTime - LastTimeVal; if (dTimeVal >= 1000) { CameraFrameVal = CGCamFrameCount; CGCamFrameCount = 0; LastTimeVal = unixTime; //Console.WriteLine("dTime " + unixTime + ", camZhenLv " + CamZhenLvVal); } } } if (CSampleGrabberCB.GetInstance() != null) { CSampleGrabberCB.GetInstance().BufferCB(unixTime, mBufHandle, CGCameraBufLen); } }
public static XKOpenCGCamera GetInstance() { if (_Instance == null) { GameObject obj = new GameObject(); DontDestroyOnLoad(obj); obj.name = "XKCGCameraCtrl"; _Instance = obj.AddComponent <XKOpenCGCamera>(); CSampleGrabberCB.GetInstance(); } return(_Instance); }
// Update is called once per frame void Update() { if (Input.GetKeyUp(KeyCode.F4)) { InitJiaoZhunZuoBiao(); } if (Input.GetKeyUp(KeyCode.G)) { // ChangeJiaoZhunPic(); //test. if (JiaoZhunCrossImg.enabled) { CSampleGrabberCB.GetInstance().ActiveJiaoZhunZuoBiao(); } } ChangeJiaoZhunPic(); }
void InitJiaoZhunZuoBiao() { if (JiaoZhunCrossImg == null || JiaoZhunCrossImg.enabled) { return; } Debug.Log("InitJiaoZhunZuoBiao!"); // ZhunXingZB.Visible = false; // ZhunXingP1.Visible = false; XKPlayerCrossCtrl.SetAllCrossActive(false); IndexCrossJZ = 0; ChangeJiaoZhunPic(); JiaoZhunCrossImg.enabled = true; if (CSampleGrabberCB.GetInstance() != null) { CSampleGrabberCB.GetInstance().InitJiaoZhunZuoBiao(); } }
void Update() { if (SetBtSt == ButtonState.DOWN && Time.time - TimeSetMoveBt > 1f && Time.frameCount % 200 == 0) { MoveStarImg(); } if (Input.GetKeyUp(KeyCode.G)) { if (SpriteAdjustGunCross.enabled) { CSampleGrabberCB.GetInstance().ActiveJiaoZhunZuoBiao(); } } if (IsJiaoZhunLaser) { IsJiaoZhunLaser = false; HanldeClickFireBtEvent(); } }
public void SendMessage() { if (!MyCOMDevice.IsFindDeviceDt) { return; } byte[] buffer = new byte[HID_BUF_LEN]; buffer[0] = WriteHead_1; buffer[1] = WriteHead_2; buffer[HID_BUF_LEN - 2] = WriteEnd_1; buffer[HID_BUF_LEN - 1] = WriteEnd_2; int iSeed = (int)DateTime.Now.ToBinary(); Random ra = new Random(iSeed); buffer[6] = (byte)ra.Next(0, 253); byte jiGuangQiCount = CSampleGrabberCB.IndexMousePoint; //buffer[7]: 0 -> 激光器P1, 1 -> 激光器P2. switch (CSampleGrabberCB.m_mode) { case MODE.MODE_MOTION: if (!CSampleGrabberCB.IsCGCameraQuickCOM) { if (IsCloseAllJiGuangQi) { //用于冷却关闭所有激光器,确保摄像机画面同一时刻只有一个激光点. buffer[7] = 0x00; IsCloseAllJiGuangQi = false; if (CSampleGrabberCB.GetInstance() != null) { CSampleGrabberCB.GetInstance().AddIndexMousePoint(); } } else { if (jiGuangQiCount % CSampleGrabberCB.JiGuangLQ == 0) { buffer[7] = (byte)(0x01 << (jiGuangQiCount / CSampleGrabberCB.JiGuangLQ)); } } } else { if (jiGuangQiCount % CSampleGrabberCB.JiGuangLQ == 0) { buffer[7] = (byte)(0x01 << (jiGuangQiCount / CSampleGrabberCB.JiGuangLQ)); } else { //用于冷却关闭所有激光器,确保摄像机画面同一时刻只有一个激光点. buffer[7] = 0x00; } } //ScreenLog.Log("jiGuangQiCount *** "+jiGuangQiCount+ //", buf07 -> "+buffer[7]+ //", IsCloseAllJiGuangQi -> "+IsCloseAllJiGuangQi); break; case MODE.MODE_SET_CALIBRATION: buffer[7] = 0xFF; break; } MyCOMDevice.ComThreadClass.WriteByteMsg = buffer; // byte[] bufferTmp = {0x02, 0x55, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x59, 0x00, 0xd1, 0xbe, 0x2c, 0xdb, // 0xb5, 0x82, 0x4d, 0x03, 0x59, 0x39, 0x4a, 0x6e, 0x80, 0x06, 0x26, 0x0a, 0x2a, 0x2c, 0x0d, 0x0a}; // MyCOMDevice.ComThreadClass.WriteByteMsg = bufferTmp; }