// ----------------- UpdateInfos ------------------------- // private void UpdateInfos() { listBoxInfo.Items.Clear(); int ver = Uc480.GetDLLVersion(); string strText; strText = String.Format("uc480 SDK Version: {0}.{1}.{2}", (ver >> 24), (ver >> 16 & 0xff), (ver & 0xffff)); listBoxInfo.Items.Add(strText); int nrOfCameras = 0; Uc480.GetNumberOfCameras(ref nrOfCameras); strText = String.Format("Connected cameras: {0}", nrOfCameras); listBoxInfo.Items.Add(strText); // camera infos if (m_uc480.IsOpen()) { listBoxInfo.Items.Add(""); // Sensorinfo Uc480.SENSORINFO sensorInfo = new Uc480.SENSORINFO(); m_uc480.GetSensorInfo(ref sensorInfo); listBoxInfo.Items.Add("Sensor: " + sensorInfo.strSensorName); // Camerainfo Uc480.CAMINFO cameraInfo = new Uc480.CAMINFO(); m_uc480.GetCameraInfo(ref cameraInfo); listBoxInfo.Items.Add("CameraInfo:"); listBoxInfo.Items.Add(" SerNo: " + cameraInfo.SerNo); listBoxInfo.Items.Add(" Date: " + cameraInfo.Date); listBoxInfo.Items.Add(" Version: " + cameraInfo.Version); strText = String.Format(" Camera ID: {0}", cameraInfo.id); listBoxInfo.Items.Add(strText); // Memory board query listBoxInfo.Items.Add(""); strText = m_uc480.IsMemoryBoardConnected() ? "Memoryboard connected" : "No Memoryboard connected"; listBoxInfo.Items.Add(strText); } }
// ------------------------ btnInit_Click ------------------------------- // private void btnInit_Click(object sender, System.EventArgs e) { // if opened before, close now if (m_uc480.IsOpen()) { m_uc480.ExitCamera(); } // open a camera int nRet = m_uc480.InitCamera(0, DisplayWindow.Handle.ToInt32()); if (nRet == Uc480.IS_STARTER_FW_UPLOAD_NEEDED) { /************************************************************************************************/ /* */ /* If the camera returns with "IS_STARTER_FW_UPLOAD_NEEDED", an upload of a new firmware */ /* is necessary. This upload can take several seconds. We recommend to check the required */ /* time with the function is_GetDuration(). */ /* */ /* In this case, the camera can only be opened if the flag "IS_ALLOW_STARTER_FW_UPLOAD" */ /* is "OR"-ed to m_hCam. This flag allows an automatic upload of the firmware. */ /* */ /************************************************************************************************/ uint nUploadTime = 25000; m_uc480.GetDuration(Uc480.IS_SE_STARTER_FW_UPLOAD, ref nUploadTime); String Str; Str = "This camera requires a new firmware. The upload will take about " + nUploadTime / 1000 + " seconds. Please wait ..."; MessageBox.Show(Str, "uc480"); nRet = m_uc480.InitCamera(0 | Uc480.IS_ALLOW_STARTER_FW_UPLOAD, DisplayWindow.Handle.ToInt32()); } if (nRet != Uc480.IS_SUCCESS) { MessageBox.Show("Init failed", "uc480"); return; } Uc480.SENSORINFO sensorInfo = new Uc480.SENSORINFO(); m_uc480.GetSensorInfo(ref sensorInfo); // Set the image size int x = 0; int y = 0; unsafe { int nAOISupported = -1; IntPtr pnAOISupported = (IntPtr)((uint *)&nAOISupported); bool bAOISupported = true; // check if an arbitrary AOI is supported //if (m_uc480.ImageFormat(uc480.IMGFRMT_CMD_GET_ARBITRARY_AOI_SUPPORTED, pnAOISupported, 4) == uc480.IS_SUCCESS) //{ // bAOISupported = (nAOISupported != 0); //} // If an arbitrary AOI is supported -> take maximum sensor size if (bAOISupported) { x = sensorInfo.nMaxWidth; y = sensorInfo.nMaxHeight; } // Take the image size of the current image format else { x = m_uc480.SetImageSize(Uc480.IS_GET_IMAGE_SIZE_X, 0); y = m_uc480.SetImageSize(Uc480.IS_GET_IMAGE_SIZE_Y, 0); } m_uc480.SetImageSize(x, y); } // alloc images m_uc480.ClearSequence(); int nLoop = 0; for (nLoop = 0; nLoop < IMAGE_COUNT; nLoop++) { // alloc memory m_uc480.AllocImageMem(x, y, 32, ref m_Uc480Images[nLoop].pMemory, ref m_Uc480Images[nLoop].MemID); // add our memory to the sequence m_uc480.AddToSequence(m_Uc480Images[nLoop].pMemory, m_Uc480Images[nLoop].MemID); // set sequence number m_Uc480Images[nLoop].nSeqNum = nLoop + 1; } m_uc480.SetColorMode(Uc480.IS_SET_CM_RGB32); m_uc480.EnableMessage(Uc480.IS_FRAME, this.Handle.ToInt32()); btnInitCam.Enabled = false; btnExit.Enabled = true; btnLive.Enabled = true; btnFreeze.Enabled = true; UpdateInfos(); // free image if (DisplayWindow.Image != null) { DisplayWindow.Image.Dispose(); DisplayWindow.Image = null; } // capture a single image m_uc480.FreezeVideo(Uc480.IS_WAIT); Refresh(); }