/// <summary> /// Constructs a new IMAQ camera on the /// specified camera link interface /// </summary> /// <param name="interfaceId">The interface name. Optionally followed by ::# identifying the port - 0 based</param> public CameraLinkCamera(string interfaceId) { //Attach to interface NIImaq.CheckError(NIImaq.imgInterfaceOpen(interfaceId, out _ifid)); //Open session NIImaq.CheckError(NIImaq.imgSessionOpen(_ifid, out _sid)); //Get image dimensions NIImaq.CheckError(NIImaq.imgGetAttribute(_sid, ImaqAttribute.IMG_ATTR_ROI_WIDTH, out _width)); NIImaq.CheckError(NIImaq.imgGetAttribute(_sid, ImaqAttribute.IMG_ATTR_ROI_HEIGHT, out _height)); NIImaq.CheckError(NIImaq.imgGetAttribute(_sid, ImaqAttribute.IMG_ATTR_BYTESPERPIXEL, out _bytesPerPixel)); System.Diagnostics.Debug.WriteLine("Bytes per pixel {0}", _bytesPerPixel); NIImaq.CheckError(NIImaq.imgGetAttribute(_sid, ImaqAttribute.IMG_ATTR_BITSPERPIXEL, out _bitsPerPixel)); if (_bytesPerPixel == 2 && _bitsPerPixel < 16) { _scaleFactor = 1; _scaleFactor <<= (16 - (int)_bitsPerPixel); } else { _scaleFactor = 1; } System.Diagnostics.Debug.WriteLine("Bits per pixel {0}", _bitsPerPixel); System.Diagnostics.Debug.WriteLine("Frame width: {0}", _width); System.Diagnostics.Debug.WriteLine("Frame height: {0}", _height); //Unfortunately there is now way (?) to nicely align the camera buffers on 4-byte boundary for ipp //The user generated image wrappers will expect this however - so for now do NOT allow to //start acquisition with a width which is non-dividable by 4!! System.Diagnostics.Debug.Assert(Width % 4 == 0, "At the moment for memory alignment, the class requires an image width which is dividable by 4!!"); //We also only allow images with either 1 or 2 bytes per pixel! if (BytesPerPixel < 1 || BytesPerPixel > 2) { System.Diagnostics.Debug.Assert(false, "Unknown pixel depth", "Currently a pixel depth of {0} bytes is not supported", BytesPerPixel); } }