private void SetFramegrabberValue(String nodeName, Int64 int64Val) { if (null == myCamera) { return; } IntPtr hDevice = IntPtr.Zero; Jai_FactoryWrapper.EFactoryError error = Jai_FactoryWrapper.J_Camera_GetLocalDeviceHandle(myCamera.CameraHandle, ref hDevice); if (Jai_FactoryWrapper.EFactoryError.Success != error) { return; } if (IntPtr.Zero == hDevice) { return; } IntPtr hNode; error = Jai_FactoryWrapper.J_Camera_GetNodeByName(hDevice, nodeName, out hNode); if (Jai_FactoryWrapper.EFactoryError.Success != error) { return; } if (IntPtr.Zero == hNode) { return; } error = Jai_FactoryWrapper.J_Node_SetValueInt64(hNode, false, int64Val); if (Jai_FactoryWrapper.EFactoryError.Success != error) { return; } //Special handling for Active Silicon CXP boards, which also has nodes prefixed //with "Incoming": if ("Width" == nodeName || "Height" == nodeName) { string strIncoming = "Incoming" + nodeName; IntPtr hNodeIncoming; error = Jai_FactoryWrapper.J_Camera_GetNodeByName(hDevice, strIncoming, out hNodeIncoming); if (Jai_FactoryWrapper.EFactoryError.Success != error) { return; } if (IntPtr.Zero == hNodeIncoming) { return; } error = Jai_FactoryWrapper.J_Node_SetValueInt64(hNodeIncoming, false, int64Val); } }
private void GaintextBox_TextChanged(object sender, EventArgs e) { if (myGainNode != null) { double value = Convert.ToSingle(GaintextBox.Text); myGainNode.Value = value; if (null == myCamera) { return; } IntPtr hDevice = IntPtr.Zero; Jai_FactoryWrapper.EFactoryError error = Jai_FactoryWrapper.J_Camera_GetLocalDeviceHandle(myCamera.CameraHandle, ref hDevice); if (Jai_FactoryWrapper.EFactoryError.Success != error) { return; } if (IntPtr.Zero == hDevice) { return; } IntPtr hNode; error = Jai_FactoryWrapper.J_Camera_GetNodeByName(hDevice, "Gain", out hNode); if (Jai_FactoryWrapper.EFactoryError.Success != error) { return; } if (IntPtr.Zero == hNode) { return; } Jai_FactoryWrapper.J_Node_SetValueDouble(hNode, false, value); } }
private void SetFramegrabberPixelFormat() { String nodeName = "PixelFormat"; if (null == myCamera) { return; } IntPtr hDevice = IntPtr.Zero; Jai_FactoryWrapper.EFactoryError error = Jai_FactoryWrapper.J_Camera_GetLocalDeviceHandle(myCamera.CameraHandle, ref hDevice); if (Jai_FactoryWrapper.EFactoryError.Success != error) { return; } if (IntPtr.Zero == hDevice) { return; } long pf = 0; error = Jai_FactoryWrapper.J_Camera_GetValueInt64(myCamera.CameraHandle, nodeName, ref pf); if (Jai_FactoryWrapper.EFactoryError.Success != error) { return; } UInt64 pixelFormat = (UInt64)pf; UInt64 jaiPixelFormat = 0; error = Jai_FactoryWrapper.J_Image_Get_PixelFormat(myCamera.CameraHandle, pixelFormat, ref jaiPixelFormat); if (Jai_FactoryWrapper.EFactoryError.Success != error) { return; } StringBuilder sbJaiPixelFormatName = new StringBuilder(512); uint iSize = (uint)sbJaiPixelFormatName.Capacity; error = Jai_FactoryWrapper.J_Image_Get_PixelFormatName(myCamera.CameraHandle, jaiPixelFormat, sbJaiPixelFormatName, iSize); if (Jai_FactoryWrapper.EFactoryError.Success != error) { return; } IntPtr hNode; error = Jai_FactoryWrapper.J_Camera_GetNodeByName(hDevice, nodeName, out hNode); if (Jai_FactoryWrapper.EFactoryError.Success != error) { return; } if (IntPtr.Zero == hNode) { return; } error = Jai_FactoryWrapper.J_Node_SetValueString(hNode, false, sbJaiPixelFormatName.ToString()); if (Jai_FactoryWrapper.EFactoryError.Success != error) { return; } //Special handling for Active Silicon CXP boards, which also has nodes prefixed //with "Incoming": string strIncoming = "Incoming" + nodeName; IntPtr hNodeIncoming; error = Jai_FactoryWrapper.J_Camera_GetNodeByName(hDevice, strIncoming, out hNodeIncoming); if (Jai_FactoryWrapper.EFactoryError.Success != error) { return; } if (IntPtr.Zero == hNodeIncoming) { return; } error = Jai_FactoryWrapper.J_Node_SetValueString(hNodeIncoming, false, sbJaiPixelFormatName.ToString()); }
private void replayButton_Click(object sender, EventArgs e) { // Here we have access to the stored images! Lets show them in an image window!! //Create a replay window if (myCamera != null && !myCamera.IsAsyncImageRecordingRunning && (myCamera.TotalAsyncImagesRecordedCount > 0)) { IntPtr WindowHandle = IntPtr.Zero; // Try to read get the maximum width and height by looking for "SensorWidth" and "SensorHeight" Int32 Width = 0; Int32 Height = 0; CNode WidthNode = myCamera.GetNode("Width"); CNode HeightNode = myCamera.GetNode("Height"); Width = Convert.ToInt32(WidthNode.Max); Height = Convert.ToInt32(HeightNode.Max); IntPtr nodeHandle; uint BytesPerPixel = 4; if (Jai_FactoryWrapper.J_Camera_GetNodeByName(myCamera.CameraHandle, "PixelFormat", out nodeHandle) == Jai_FactoryWrapper.EFactoryError.Success) { Int64 value = 0; if (Jai_FactoryWrapper.J_Node_GetValueInt64(nodeHandle, false, ref value) == Jai_FactoryWrapper.EFactoryError.Success) { Jai_FactoryWrapper.EPixelFormatType pixeltype = (Jai_FactoryWrapper.EPixelFormatType)value; BytesPerPixel = Jai_FactoryWrapper.GetPixelTypeMemorySize(pixeltype); } } Jai_FactoryWrapper.SIZE maxSize = new Jai_FactoryWrapper.SIZE(Width, Height); Jai_FactoryWrapper.EFactoryError error = Jai_FactoryWrapper.EFactoryError.Success; // Calculate the size of the window rect to display the images int RectWidth = 0; int RectHeight = 0; Jai_FactoryWrapper.RECT frameRect = new Jai_FactoryWrapper.RECT(0, 0, 100, 100);; // Does the image fit in width? if ((Width + 2 * System.Windows.Forms.SystemInformation.Border3DSize.Width) > System.Windows.Forms.Screen.PrimaryScreen.WorkingArea.Width) { RectWidth = System.Windows.Forms.Screen.PrimaryScreen.WorkingArea.Width - 2 * System.Windows.Forms.SystemInformation.Border3DSize.Width; } else { RectWidth = Width; } // Does the image fit in Height? if ((Height + System.Windows.Forms.SystemInformation.Border3DSize.Height + System.Windows.Forms.SystemInformation.CaptionHeight) > System.Windows.Forms.Screen.PrimaryScreen.WorkingArea.Height) { RectHeight = System.Windows.Forms.Screen.PrimaryScreen.WorkingArea.Height - System.Windows.Forms.SystemInformation.Border3DSize.Height - System.Windows.Forms.SystemInformation.CaptionHeight; } else { RectHeight = Height; } frameRect = new Jai_FactoryWrapper.RECT(0, 0, RectWidth, RectHeight); // Open the replay view error = Jai_FactoryWrapper.J_Image_OpenViewWindowEx(Jai_FactoryWrapper.EIVWWindowType.OverlappedStretch, "Replay", ref frameRect, ref maxSize, IntPtr.Zero, out WindowHandle); if (WindowHandle != IntPtr.Zero) { List <Jai_FactoryWrapper.ImageInfo> imageList = myCamera.GetAsyncRecordedImages(); if (imageList != null && (imageList.Count > 0)) { for (int index = 0; index < myCamera.TotalAsyncImagesRecordedCount; index++) { Jai_FactoryWrapper.ImageInfo ii = imageList[index]; Jai_FactoryWrapper.J_Image_SetViewWindowTitle(WindowHandle, "Replay (" + index.ToString() + "/" + myCamera.TotalAsyncImagesRecordedCount.ToString() + ")"); Jai_FactoryWrapper.J_Image_ShowImage(WindowHandle, ref ii, 4096, 4096, 4096); Application.DoEvents(); //Thread.Sleep(10); Delay(10); } } Jai_FactoryWrapper.J_Image_CloseViewWindow(WindowHandle); } } }