commit 2a44360ba8c7aca3e303720422bd7c749c9905a4 Author: Alexandre Gobbo Date: Wed May 17 17:29:16 2017 +0200 Changed Camera devices to better support Prosilica diff --git a/pom.xml b/pom.xml new file mode 100644 index 0000000..e5960b5 --- /dev/null +++ b/pom.xml @@ -0,0 +1,54 @@ + + + 4.0.0 + ch.psi + prosilica + 1.0.0 + jar + + UTF-8 + 1.8 + 1.8 + + prosilica + + + ${project.groupId} + pshell + 1.7.0 + provided + + + + + + + maven-assembly-plugin + + + src/main/assembly/src.xml + + + + ../../pshell/home/extensions + + + + + make-assembly + package + + single + + + + + + + + \ No newline at end of file diff --git a/src/main/assembly/src.xml b/src/main/assembly/src.xml new file mode 100644 index 0000000..0dd2b05 --- /dev/null +++ b/src/main/assembly/src.xml @@ -0,0 +1,29 @@ + + + + + + jar-with-dependencies + + jar + + false + + + + false + + / + true + true + runtime + + + + + + diff --git a/src/main/java/ch/psi/pshell/prosilica/Prosilica.java b/src/main/java/ch/psi/pshell/prosilica/Prosilica.java new file mode 100644 index 0000000..5010166 --- /dev/null +++ b/src/main/java/ch/psi/pshell/prosilica/Prosilica.java @@ -0,0 +1,897 @@ +/* + * Copyright (c) 2014 Paul Scherrer Institute. All rights reserved. + */ +package ch.psi.pshell.prosilica; + +import ch.psi.pshell.device.Camera; +import ch.psi.pshell.device.CameraBase; +import ch.psi.pshell.device.ReadonlyRegister.ReadonlyRegisterArray; +import ch.psi.pshell.device.ReadonlyRegisterBase; +import ch.psi.pshell.imaging.Source.EmbeddedCameraSource; +import ch.psi.pshell.imaging.SourceBase; +import ch.psi.pshell.imaging.Renderer; +import java.io.File; +import java.io.IOException; +import java.nio.ByteBuffer; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.logging.Logger; +import java.awt.image.BufferedImage; +import java.awt.image.DataBufferByte; +import java.awt.image.DataBufferUShort; +import javax.swing.JFrame; +import ch.psi.utils.Chrono; +import ch.psi.utils.NamedThreadFactory; +import ch.psi.utils.State; +import ch.psi.utils.Sys; +import java.util.LinkedHashMap; +import java.util.concurrent.Executors; +import java.util.concurrent.ScheduledExecutorService; +import java.util.concurrent.ScheduledFuture; +import java.util.concurrent.TimeUnit; +import java.util.logging.Level; + +import prosilica.Pv; + +public class Prosilica extends SourceBase implements EmbeddedCameraSource { + + final long uid; + final HashMap pars; + final boolean monitor; + + volatile boolean opened; + volatile boolean started; + + Pv.tHandle handle; + Pv.tFrame[] frames; + ByteBuffer brgBuffer; + boolean cameraTimeout; + long currentUid = -1; + String format; + + final int IMAGE_BUFFER_SIZE = 5; + + // constructor + public Prosilica(String name, long uid, String pars) { + super(name); + this.uid = uid; + this.monitor = "monitor".equalsIgnoreCase(pars); + this.pars = new LinkedHashMap<>(); + if ((pars != null) && (pars.trim().length() != 0) && !monitor) { + for (String token : pars.split(";")) { + String[] entry = token.split("="); + if ((entry.length == 2) && (!entry[0].trim().isEmpty()) && (!entry[1].trim().isEmpty())) { + String parName = entry[0].trim(); + Object parVal = entry[1].trim(); + try { + parVal = Integer.parseInt((String) parVal); + } catch (Exception ex) { + try { + parVal = Float.parseFloat((String) parVal); + } catch (Exception e) { + } + } + this.pars.put(parName, parVal); + } + } + } + setMonitored(true); + } + + void writePars() throws IOException { + for (String par : pars.keySet()) { + writeParameter(par, pars.get(par)); + } + } + + /////////////////////////////////////////////////////////////////////////////////////////////// + //Monitoring + /////////////////////////////////////////////////////////////////////////////////////////////// + static ScheduledExecutorService schedulerWatchDog; + ScheduledFuture watchDogScheduledFuture; + boolean timedOut; + + public void startWatchDogTimer(long timeout) { + if (schedulerWatchDog == null) { + schedulerWatchDog = Executors.newSingleThreadScheduledExecutor( + new NamedThreadFactory("Prosilica watchdog scheduler")); + } + watchDogScheduledFuture = schedulerWatchDog.scheduleWithFixedDelay(() -> { + try { + if (started || timedOut) { + Integer age = getAge(); + if ((age == null) || (age > timeout)) { + if (!timedOut) { + getLogger().warning("Detected camera timeout - Reinitializing"); + } + timedOut = true; + initialize(); + timedOut = false; + getLogger().warning("Camera was successfully reinitialized"); + } + } + } catch (Exception ex) { + getLogger().log(Level.FINER, null, ex); + } + }, timeout, timeout, TimeUnit.MILLISECONDS); + } + + public void stopWatchDogTimer() { + if (watchDogScheduledFuture != null) { + watchDogScheduledFuture.cancel(true); + watchDogScheduledFuture = null; + } + } + + /////////////////////////////////////////////////////////////////////////////////////////////// + //Initialization + /////////////////////////////////////////////////////////////////////////////////////////////// + @Override + protected void doInitialize() throws IOException, InterruptedException { + super.doInitialize(); + instances++; + doClose(); + loadPvapi(); + opened = true; + + try { + waitCamera(uid, 5000); + + if (uid > 0) { + openCamera(uid); + } else { + HashMap[] info = getCameras(); + if (info.length == 0) { + throw new IOException("No camera detected"); + } + openCamera((Long) info[0].get("uid")); + } + setState(State.Ready); + writePars(); + camera.initialize(); + start(); + } catch (IOException ex) { + getLogger().warning("Error opening the camera: " + ex.getMessage()); + throw ex; + } + } + + @Override + public void doClose() throws IOException { + try { + if (opened) { + opened = false; + started = false; + instances--; + try { + stop(); + } catch (Exception ex) { + } + try { + closeCamera(); + } catch (Exception ex) { + } + try { + camera.close(); + } catch (Exception ex) { + } + if (instances == 0) { + disposePvapi(); + } + } + } catch (Exception ex) { + } + super.doClose(); + } + + private boolean isStreaming() { + return (handle != null) && Pv.CaptureQuery(handle); + } + + public void start() throws IOException, InterruptedException { + assertInitialized(); + if (started) { + return; + } + pushImage(null); + Thread.sleep(1); + cameraTimeout = false; + this.format = null; + Pv.tUint32 width = new Pv.tUint32(); + Pv.tUint32 height = new Pv.tUint32(); + Pv.tUint32 length = new Pv.tUint32(); + Pv.tString format = new Pv.tString(); + + if (Pv.AttrUint32Get(handle, "TotalBytesPerFrame", length) != Pv.tError.eSuccess + || Pv.AttrUint32Get(handle, "Width", width) != Pv.tError.eSuccess + || Pv.AttrUint32Get(handle, "Height", height) != Pv.tError.eSuccess + || Pv.AttrEnumGet(handle, "PixelFormat", format) != Pv.tError.eSuccess) { + throw new IOException("Error configuring camera"); + } + this.format = format.Value; + int imageType; + switch (this.format) { + case "Mono8": + imageType = BufferedImage.TYPE_BYTE_GRAY; + case "Mono16": + imageType = BufferedImage.TYPE_USHORT_GRAY; + default: + imageType = BufferedImage.TYPE_3BYTE_BGR; + } + + createImageBuffer(IMAGE_BUFFER_SIZE, (int) width.Value, (int) height.Value, imageType); + createFrameBuffer(IMAGE_BUFFER_SIZE, (int) length.Value); + + brgBuffer = (imageType == BufferedImage.TYPE_3BYTE_BGR) ? ByteBuffer.allocateDirect((int) width.Value * (int) height.Value * 3 + 5000) : null; + + if (Pv.CaptureStart(handle) != Pv.tError.eSuccess) { + throw new IOException("Error starting camera"); + } + + for (int i = 0; i < IMAGE_BUFFER_SIZE; i++) { + if (Pv.CaptureQueueFrame(handle, frames[i], frameListener) != Pv.tError.eSuccess) { + //Retry with new buffer + Logger.getLogger(Prosilica.class.getName()).warning("Error setting frame queue: retrying with new buffer"); + frames[i] = new Pv.tFrame(); + frames[i].ImageBuffer = ByteBuffer.allocateDirect((int) length.Value); + if (Pv.CaptureQueueFrame(handle, frames[i], frameListener) != Pv.tError.eSuccess) { + throw new IOException("Error setting frame queue"); + } + break; + } + } + + if (Pv.CommandRun(handle, "AcquisitionStart") != Pv.tError.eSuccess) { + throw new IOException("Error startic acquisition"); + } + started = true; + } + + public void stop() throws IOException { + assertInitialized(); + started = false; + currentFrame = null; + if (isStreaming()) { + Pv.CommandRun(handle, "AcquisitionStop"); + Pv.CaptureQueueClear(handle); + Pv.CaptureEnd(handle); + } + } + + public boolean isStarted() { + return started; + } + + public HashMap getInfoDict() throws IOException { + if (currentUid > 0) { + Pv.tCameraInfo info = new Pv.tCameraInfo(); + Pv.CameraInfo(currentUid, info); + return getInfo(info); + } + return null; + } + + static private HashMap getInfo(Pv.tCameraInfo info) { + HashMap ret = new HashMap(); + ret.put("uid", info.UniqueId); + ret.put("serial", info.SerialString); + ret.put("partno", info.PartNumber); + ret.put("version", info.PartVersion); + ret.put("access", info.PermittedAccess); + ret.put("intid", info.InterfaceId); + ret.put("name", info.DisplayName); + return ret; + } + +/////////////////////////////////////////////////////////////////////////////////////////////// +//PvAPI initialization +/////////////////////////////////////////////////////////////////////////////////////////////// + private static int instances = 0; + private static boolean loadedPvapi = false; + + private static void loadPvapi() throws IOException { + if (loadedPvapi == false) { + Logger.getLogger(Prosilica.class.getName()).info("Loading PvAPI"); + + if (Pv.Initialize() == Pv.tError.eSuccess) { + loadedPvapi = true; + } else { + throw new IOException("Error loading PvAPI"); + } + } + } + + private static void disposePvapi() { + if (loadedPvapi) { + Logger.getLogger(Prosilica.class.getName()).info("Disposing PvAPI"); + try { + Pv.UnInitialize(); + loadedPvapi = false; + } catch (Exception ex) { + } + } + } + + private static void waitCamera(Long uid, int timeout) throws IOException, InterruptedException { + Chrono chrono = new Chrono(); + while (true) { + for (HashMap info : getCameras()) { + if ((uid == null) || uid.equals(info.get("uid"))) { + return; + } + } + if ((timeout > 0) && chrono.isTimeout(timeout)) { + throw new IOException("No camera detected"); + } + Thread.sleep(10); + } + } + +/////////////////////////////////////////////////////////////////////////////////////////////// +//Camera selection +/////////////////////////////////////////////////////////////////////////////////////////////// + public static HashMap[] getCameras() { + if (loadedPvapi == false) { + try { + loadPvapi(); + waitCamera(null, 500); + Thread.sleep(100); + } catch (Exception ex) { + } + } + ArrayList ret = new ArrayList<>(); + + Pv.tCameraInfo[] cameras = new Pv.tCameraInfo[10]; + int cameras_count = Pv.CameraList(cameras, 10); + for (int i = 0; i < cameras_count; i++) { + ret.add(getInfo(cameras[i])); + } + return ret.toArray(new HashMap[0]); + } + + public void openCamera(long uid) throws IOException, InterruptedException { + currentUid = uid; + if (handle != null) { + closeCamera(); + Thread.sleep(250); + } + if (uid > 0) { + getLogger().info("Open camera " + String.valueOf(uid)); + if (handle == null) { + handle = new Pv.tHandle(); + } + int flags = monitor ? Pv.tAccessFlags.eMonitor : Pv.tAccessFlags.eMaster; + if (Pv.CameraOpen(uid, flags, handle) != Pv.tError.eSuccess) { + throw new IOException("Error setting camera: " + currentUid); + } + } + } + + public void closeCamera() throws IOException { + if (handle != null) { + getLogger().info("Close camera " + String.valueOf(this.currentUid)); + try { + stop(); + } catch (Exception ex) { + getLogger().log(Level.WARNING, null, ex); + } + Pv.tError ret = Pv.tError.eUnavailable; + ret = Pv.CameraClose(handle); + handle = null; + } + } + + ////////////////////////////////////////////////////////////////////////////////////////////////////////// + //Parameters access + ////////////////////////////////////////////////////////////////////////////////////////////////////////// + public void writeParameter(String name, Object value) throws IOException { + if (handle == null) { + throw new IOException("Camera not initialized"); + } + if (Pv.AttrExists(handle, name) != Pv.tError.eSuccess) { + throw new IOException("Invalid parameter: " + name); + } + if ((value instanceof Float) || (value instanceof Double)) { + Pv.AttrFloat32Set(handle, name, ((Number) value).floatValue()); + } else if (value instanceof Number) { + Pv.AttrUint32Set(handle, name, ((Number) value).intValue()); + } else if (value instanceof String) { + Pv.AttrStringSet(handle, name, (String) value); + } else { + throw new IOException("Unsuporter type: " + value.getClass().getSimpleName()); + } + } + + public Object readParameter(String name) throws IOException { + if (handle == null) { + throw new IOException("Camera not initialized"); + } + if (Pv.AttrExists(handle, name) != Pv.tError.eSuccess) { + throw new IOException("Invalid parameter: " + name); + } + Pv.tFloat32 float_val = new Pv.tFloat32(); + if (Pv.AttrFloat32Get(handle, name, float_val) == Pv.tError.eSuccess) { + return Double.valueOf(float_val.Value); + } + Pv.tUint32 int_val = new Pv.tUint32(); + if (Pv.AttrUint32Get(handle, name, int_val) == Pv.tError.eSuccess) { + return Integer.valueOf((int) int_val.Value); + } + Pv.tString str_val = new Pv.tString(); + if (Pv.AttrStringGet(handle, name, str_val) == Pv.tError.eSuccess) { + return str_val.Value; + } + throw new IOException("Invalid parameter: " + name); + } + + public Object readParameterRange(String name) throws IOException { + if (handle == null) { + throw new IOException("Camera not initialized"); + } + if (Pv.AttrExists(handle, name) != Pv.tError.eSuccess) { + throw new IOException("Invalid parameter: " + name); + } + Pv.tRangeFloat32 rangef = new Pv.tRangeFloat32(); + if (Pv.AttrRangeFloat32(handle, name, rangef) == Pv.tError.eSuccess) { + return new float[]{rangef.Min, rangef.Max}; + } + Pv.tRangeUint32 rangei = new Pv.tRangeUint32(); + if (Pv.AttrRangeUint32(handle, name, rangei) == Pv.tError.eSuccess) { + return new long[]{rangei.Min, rangei.Max}; + } + Pv.tStringsList range = new Pv.tStringsList(); + if (Pv.AttrRangeEnum(handle, name, range) == Pv.tError.eSuccess) { + return range.Array; + } + throw new IOException("Invalid parameter: " + name); + } + + /////////////////////////////////////////////////////////////////////////////////////////////// + // Image buffer + /////////////////////////////////////////////////////////////////////////////////////////////// + private BufferedImage[] imageBuffer = null; + volatile int imageBufferIndex = 0; + + public HashMap getImageProperties() { + HashMap ret = new HashMap(); + ret.put("buffer", imageBuffer.length); + ret.put("width", imageBuffer[0].getWidth()); + ret.put("height", imageBuffer[0].getHeight()); + ret.put("type", imageBuffer[0].getType()); + return ret; + } + + void createFrameBuffer(int size, int frame_length) { + if ((frames == null) || (frames.length == 0) || (frames.length != size)) { + frames = new Pv.tFrame[size]; + for (int i = 0; i < size; i++) { + frames[i] = new Pv.tFrame(); + frames[i].ImageBuffer = ByteBuffer.allocateDirect(frame_length); + } + } else if (frames[0].ImageBuffer.capacity() < frame_length) { + for (int i = 0; i < size; i++) { + frames[i].ImageBuffer = ByteBuffer.allocateDirect(frame_length); + } + } + } + + void createImageBuffer(int size, int width, int height, int type) { + imageBufferIndex = 0; + imageBuffer = new BufferedImage[size]; + for (int i = 0; i < size; i++) { + imageBuffer[i] = new BufferedImage(width, height, type); + } + } + + BufferedImage getImageFromBuffer() { + BufferedImage img = imageBuffer[imageBufferIndex]; + imageBufferIndex++; + if (imageBufferIndex >= imageBuffer.length) { + imageBufferIndex = 0; + } + return img; + } + + /////////////////////////////////////////////////////////////////////////////////////////////// + //Frame event callback + /////////////////////////////////////////////////////////////////////////////////////////////// + volatile Pv.tFrame currentFrame; + final Pv.FrameListener frameListener = new Pv.FrameListener() { + @Override + public void onFrameEvent(Pv.tFrame frame) { + synchronized (Prosilica.this) { + if (started && (frame.Status != Pv.tError.eCancelled)) { + BufferedImage img = getImageFromBuffer(); + if (convertFrameToImage(frame, img)) { + currentFrame = frame; + pushImage(img); + } else { + currentFrame = null; + pushImage(null); + } + Pv.CaptureQueueFrame(handle, frame, this); + cameraTimeout = false; + } + } + } + }; + + protected boolean convertFrameToImage(Pv.tFrame frame, BufferedImage image) { + boolean ret = true; + + if (frame.Format == Pv.tImageFormat.eMono8 || frame.Format == Pv.tImageFormat.eBgr24) { + DataBufferByte buffer = (DataBufferByte) image.getRaster().getDataBuffer(); + byte[] data = buffer.getData(); + + if (frame.ImageBuffer.hasArray()) { + System.arraycopy(frame.ImageBuffer.array(), 0, data, 0, (int) frame.ImageSize); + } else { + frame.ImageBuffer.get(data, 0, (int) frame.ImageSize); + frame.ImageBuffer.rewind(); + } + } else if (frame.Format == Pv.tImageFormat.eMono16) { + DataBufferUShort buffer = (DataBufferUShort) image.getRaster().getDataBuffer(); + short[] data = buffer.getData(); + int Shift = frame.BitDepth - 8; + + frame.ImageBuffer.order(java.nio.ByteOrder.LITTLE_ENDIAN); + + for (int i = 0, j = 0; i < frame.ImageSize; i += 2, j++) { + data[j] = (short) (frame.ImageBuffer.getShort(i) << Shift); + } + + frame.ImageBuffer.rewind(); + } else { + DataBufferByte buffer = (DataBufferByte) image.getRaster().getDataBuffer(); + byte[] data = buffer.getData(); + if (brgBuffer != null) { + ret = Pv.FrameToBGRBuffer(frame, brgBuffer) == Pv.tError.eSuccess; + if (ret) { + brgBuffer.get(data, 0, data.length); + brgBuffer.rewind(); + } + } + } + return ret; + } + + /////////////////////////////////////////////////////////////////////////////////////////////// + //Camera interface + /////////////////////////////////////////////////////////////////////////////////////////////// + public Camera getCamera() { + return camera; + } + + final Camera camera = new CameraBase(Prosilica.this.getName() + " camera") { + @Override + protected void doStart() throws IOException, InterruptedException { + Prosilica.this.start(); + } + + @Override + protected void doStop() throws IOException, InterruptedException { + Prosilica.this.stop(); + } + + @Override + protected boolean getStarted() throws IOException, InterruptedException { + return Prosilica.this.isStarted(); + } + + class ProsilicaData extends ReadonlyRegisterBase implements ReadonlyRegisterArray { + + @Override + protected Object doRead() throws IOException, InterruptedException { + if (currentFrame != null) { + if (currentFrame.ImageBuffer.hasArray()) { + return currentFrame.ImageBuffer.array(); + } + } + return null; + } + + @Override + public int getSize() { + if (currentFrame != null) { + return (int) currentFrame.ImageSize; + } + return 0; + } + } + + final ProsilicaData data = new ProsilicaData(); + + @Override + public ReadonlyRegisterArray getDataArray() { + return data; + } + + @Override + public String getInfo() throws IOException, InterruptedException { + HashMap infoDict = getInfoDict(); + return infoDict == null ? "" : infoDict.get("name") + " - uid: " + infoDict.get("uid"); + } + + @Override + public int[] getSensorSize() throws IOException, InterruptedException { + return new int[]{(Integer) readParameter("SensorWidth"), (Integer) readParameter("SensorHeight")}; + } + + @Override + public void setBinningX(int value) throws IOException, InterruptedException { + writeParameter("BinningX", value); + } + + @Override + public int getBinningX() throws IOException, InterruptedException { + return (Integer) readParameter("BinningX"); + } + + @Override + public void setBinningY(int value) throws IOException, InterruptedException { + writeParameter("BinningY", value); + } + + @Override + public int getBinningY() throws IOException, InterruptedException { + return (Integer) readParameter("BinningY"); + } + + @Override + public void setROI(int x, int y, int w, int h) throws IOException, InterruptedException { + writeParameter("RegionX", 0); + writeParameter("RegionY", 0); + writeParameter("Height", h); + writeParameter("Width", w); + writeParameter("RegionX", x); + writeParameter("RegionY", y); + } + + @Override + public int[] getROI() throws IOException, InterruptedException { + return new int[]{(Integer) readParameter("RegionX"), (Integer) readParameter("RegionY"), + (Integer) readParameter("Width"), (Integer) readParameter("Height"),}; + } + + @Override + public void setGain(double value) throws IOException, InterruptedException { + writeParameter("GainValue", (int) value); + } + + @Override + public double getGain() throws IOException, InterruptedException { + return (Integer) readParameter("GainValue"); + } + + @Override + public void setDataType(DataType type) throws IOException, InterruptedException { + setPixelFormat(getColorMode(), type); + } + + @Override + public DataType getDataType() throws IOException, InterruptedException { + //TODO: Color mode is linked to EPICS. + switch ((String) readParameter("PixelFormat")) { + case "Mono8": + case "Bayer8": + return DataType.UInt8; + case "Mono16": + case "Bayer16": + return DataType.UInt16; + case "Rgb24": + case "Brg24": + return DataType.Int24; + case "Rgba32": + case "Brga32": + return DataType.Int32; + default: + return null; + } + } + + void setPixelFormat(ColorMode mode, DataType type) throws IOException { + String pixelFormat = null; + switch (mode) { + case Mono: + pixelFormat = "Mono"; + break; + case RGB1: + pixelFormat = "Rgb"; + break; + case RGB2: + pixelFormat = "Brg"; + break; + case RGB3: + pixelFormat = "Bayer"; + break; + } + switch (type.getSize()) { + case 1: + pixelFormat += "8"; + break; + case 2: + pixelFormat += "16"; + break; + case 3: + pixelFormat += "24"; + break; + case 4: + pixelFormat += "a32"; + break; + } + writeParameter("PixelFormat", pixelFormat); + } + + @Override + public void setColorMode(ColorMode mode) throws IOException, InterruptedException { + setPixelFormat(mode, getDataType()); + } + + @Override + public ColorMode getColorMode() throws IOException, InterruptedException { + switch ((String) readParameter("PixelFormat")) { + case "Mono8": + case "Mono16": + return ColorMode.Mono; + case "Rgb24": + case "Rgba32": + return ColorMode.RGB1; + case "Brga24": + case "Brga32": + return ColorMode.RGB2; + case "Bayer8": + case "Bayer16": + return ColorMode.RGB3; + default: + return null; + } + } + + @Override + public int[] getImageSize() throws IOException, InterruptedException { + return new int[]{(Integer) readParameter("Width"), (Integer) readParameter("Height")}; + } + + @Override + public void setExposure(double value) throws IOException, InterruptedException { + writeParameter("ExposureValue", (int) (value * 1000)); + } + + @Override + public double getExposure() throws IOException, InterruptedException { + return ((Integer) readParameter("ExposureValue")).floatValue() / 1000; + } + + @Override + public void setAcquirePeriod(double value) throws IOException, InterruptedException { + writeParameter("FrameRate", 1000.0 / (value)); + } + + @Override + public double getAcquirePeriod() throws IOException, InterruptedException { + return 1000.0 / ((Double) readParameter("FrameRate")); + } + + @Override + public void setNumImages(int value) throws IOException, InterruptedException { + writeParameter("AcquisitionFrameCount", value); + } + + @Override + public int getNumImages() throws IOException, InterruptedException { + return (Integer) readParameter("AcquisitionFrameCount"); + } + + @Override + public void setIterations(int value) throws IOException, InterruptedException { + //TODO + } + + @Override + public int getIterations() throws IOException, InterruptedException { + return 1; + } + + @Override + public int getImagesComplete() throws IOException, InterruptedException { + return (Integer) readParameter("StatFramesCompleted"); + } + + @Override + public void setGrabMode(GrabMode value) throws IOException, InterruptedException { + String acquisitionMode; + switch (value) { + case Continuous: + acquisitionMode = "Continuous"; + break; + case Single: + acquisitionMode = "SingleFrame"; + break; + case Multiple: + acquisitionMode = "MultiFrame"; + break; + default: + throw new IOException("Not supported mode: " + value); + } + writeParameter("AcquisitionMode", acquisitionMode); + } + + @Override + public GrabMode getGrabMode() throws IOException, InterruptedException { + switch ((String) readParameter("AcquisitionMode")) { + case "Continuous": + return GrabMode.Continuous; + case "SingleFrame": + return GrabMode.Single; + case "MultiFrame": + return GrabMode.Multiple; + case "Recorder": + default: + return null; + } + } + + @Override + public void setTriggerMode(TriggerMode value) throws IOException, InterruptedException { + String triggerMode = null; + switch (value) { + case Free_Run: + triggerMode = "Freerun"; + break; + case External: + triggerMode = "SyncIn1"; + break; + case Software: + triggerMode = "Software"; + break; + case Fixed_Rate: + triggerMode = "FixedRate"; + break; + } + writeParameter("FrameStartTriggerMode", triggerMode); + } + + @Override + public TriggerMode getTriggerMode() throws IOException, InterruptedException { + switch ((String) readParameter("FrameStartTriggerMode")) { + case "Freerun": + return TriggerMode.Free_Run; + case "SyncIn1": + return TriggerMode.External; + case "Software": + return TriggerMode.Software; + case "FixedRate": + return TriggerMode.Fixed_Rate; + default: + return null; + } + } + + @Override + public void trigger() throws IOException, InterruptedException { + Pv.tError ret = Pv.CommandRun(handle, "FrameStartTriggerSoftware"); + if (ret != Pv.tError.eSuccess) { + throw new IOException("Software trigger error: " + ret.toString()); + } + + } + }; + + public static void main(String[] args) throws Exception { + Sys.addToLibraryPath(new File("home/extensions").getCanonicalPath()); + //Prosilica prosilica = new Prosilica(null, 25001, "monitor"); + Prosilica prosilica = new Prosilica(null, 25001, "PacketSize=1504;PixelFormat=Bayer8;AcquisitionMode=Continuous;FrameRate=5.0;AcquisitionFrameCount=1"); + Prosilica.getCameras(); + + JFrame frame = new JFrame("Prosilica"); + frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); + Renderer renderer = new Renderer(); + frame.setSize(640, 480); + frame.setContentPane(renderer); + frame.setVisible(true); + prosilica.startWatchDogTimer(5000); + prosilica.initialize(); + prosilica.addListener(renderer); + //renderer.setSource(prosilica); + } +} diff --git a/src/main/java/prosilica/Pv.java b/src/main/java/prosilica/Pv.java new file mode 100644 index 0000000..8bb88b8 --- /dev/null +++ b/src/main/java/prosilica/Pv.java @@ -0,0 +1,1528 @@ +/* + ============================================================================== + Copyright (C) 2008-2014 Allied Vision Technologies. All Rights Reserved. + + Reproduction or disclosure of this file or its contents without the prior + written consent of AVT is prohibited. + =============================================================================== + + This package defines and implements a Java wrapper around PvAPI C interface, + to be used with the native shared library "PvJNI". + + ============================================================================== + + THIS SOFTWARE IS PROVIDED BY THE AUTHOR "AS IS" AND ANY EXPRESS OR IMPLIED + WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF TITLE, + NON-INFRINGEMENT, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, + INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, + OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, + EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + + ============================================================================== +*/ + +package prosilica; + +import java.nio.ByteBuffer; + +public class Pv { + + /** + * Error codes, returned by most methods of the API. + */ + public static enum tError { + + /** No error */ + eSuccess, + /** Unexpected camera fault */ + eCameraFault, + /** Unexpected fault in PvApi or driver */ + eInternalFault, + /** Camera handle is invalid */ + eBadHandle, + /** Bad parameter to API call */ + eBadParameter, + /** Sequence of API calls is incorrect */ + eBadSequence, + /** Camera or attribute not found */ + eNotFound, + /** Camera cannot be opened in the specified mode */ + eAccessDenied, + /** Camera was unplugged */ + eUnplugged, + /** Setup is invalid (an attribute is invalid) */ + eInvalidSetup, + /** System/network resources or memory not available */ + eResources, + /** 1394 bandwidth not available */ + eBandwidth, + /** Too many frames on queue */ + eQueueFull, + /** Frame buffer is too small */ + eBufferTooSmall, + /** Frame cancelled by user */ + eCancelled, + /** The data for the frame was lost */ + eDataLost, + /** Some data in the frame is missing */ + eDataMissing, + /** Timeout during wait */ + eTimeout, + /** Attribute value is out of the expected range */ + eOutOfRange, + /** Attribute is not this type (wrong access function) */ + eWrongType, + /** Attribute write forbidden at this time */ + eForbidden, + /** Attribute is not available at this time */ + eUnavailable, + /** A firewall is blocking the traffic (Windows only) */ + eFirewall + } + + //----- Camera Enumeration & Information -------------------------------------- + + /** + * API version number (Major.Minor) + */ + public static class tVersion { + + /** + * major version number + */ + public int Major; + /** + * Minor version number + */ + public int Minor; + + public tVersion() {Major = Minor = 0;} + } + + /** + * Camera access mode. Used in tCameraInfo data, and as the access mode in OpenCamera(). + */ + public static class tAccessFlags { + + /** + * Monitor access: no control, read & listen only + */ + public static final int eMonitor = 2; + /** + * Master access: full control + */ + public static final int eMaster = 4; + + public tAccessFlags() {} + } + + public static class tCameraInfoEx { + + /** Unique value for each camera */ + public long UniqueId; + /** People-friendly camera name (usually part name) */ + public String CameraName; + /** Name of camera part */ + public String ModelName; + /** Manufacturer's part number */ + public String PartNumber; + /** Camera's serial number */ + public String SerialNumber; + /** Camera's firmware version */ + public String FirmwareVersion; + /** A combination of tAccessFlags */ + public long PermittedAccess; + /** Unique value for each interface */ + public long InterfaceId; + + public tCameraInfoEx() {} + } + + /** + * Camera information (deprecated) + */ + public static class tCameraInfo { + + /** Unique value for each camera */ + public long UniqueId; + /** Camera's serial number */ + public String SerialString; + /** Camera part number */ + public long PartNumber; + /** Camera part version */ + public char PartVersion; + /** A combination of tAccessFlags */ + public long PermittedAccess; + /** Unique value for each interface */ + public long InterfaceId; + /** People-friendly camera name */ + public String DisplayName; + + public tCameraInfo() {} + } + + /** + * Ethernet configuration modes + */ + public static class tIpConfig { + + /** Use persistent IP settings */ + public static final int ePersistent = 1; + /** Use DHCP, fall-back to AutoIP */ + public static final int eDhcp = 2; + /** Use AutoIP only */ + public static final int eAutoIp = 4; + + } + + /** + * Camera Ethernet settings + * All IP values are in network byte order (i.e. big endian). + */ + public static class tIpSettings { + + /** IP configuration mode: persistent, DHCP & AutoIp, or AutoIp only. */ + public int ConfigMode = 0; + /** IP configuration mode supported by the camera */ + public int ConfigModeSupport = 0; + + /** Current IP address */ + public byte[] CurrentIpAddress = {0,0,0,0}; + /** Current subnet */ + public byte[] CurrentIpSubnet = {0,0,0,0}; + /** Current gateway */ + public byte[] CurrentIpGateway = {0,0,0,0}; + + /** Persistent IP address */ + public byte[] PersistentIpAddr = {0,0,0,0}; + /** Persistent subnet */ + public byte[] PersistentIpSubnet = {0,0,0,0}; + /** Persistent gateway */ + public byte[] PersistentIpGateway = {0,0,0,0}; + + public tIpSettings() {} + } + + // Handle to an open camera + /** + * Handle to an open camera + */ + public static class tHandle { + + protected long Handle; // Internal handle to the camera + + public tHandle() {Handle = 0;} + } + + //----- Interface-Link Callback ----------------------------------------------- + + /** + * Link (a.k.a interface) event type + */ + public static enum tLinkEvent + { + /** A camera was plugged in */ + eAdd, + /** A camera was unplugged */ + eRemove, + } + + /** + * Link (a.k.a interface) listener interface + */ + public static interface LinkListener { + + /** + * The method is called by the API when an link event occurs. + * + * @param tLinkEvent Event, Event which occurred + * @param long UniqueId, Unique ID of the camera related to the event + */ + public void onLinkEvent(tLinkEvent Event,long UniqueId); + + } + + //----- Image Capture --------------------------------------------------------- + + /** + * Supported image format + */ + public enum tImageFormat { + + /** Monochrome, 8 bits */ + eMono8, + /** Monochrome, 16 bits, data is LSB aligned */ + eMono16, + /** Bayer-color, 8 bits */ + eBayer8, + /** Bayer-color, 16 bits, data is LSB aligned */ + eBayer16, + /** RGB, 8 bits x 3 */ + eRgb24, + /** RGB, 16 bits x 3, data is LSB aligned */ + eRgb48, + /** YUV 411 */ + eYuv411, + /** YUV 422 */ + eYuv422, + /** YUV 444 */ + eYuv444, + /** BGR, 8 bits x 3 */ + eBgr24, + /** RGBA, 8 bits x 4 */ + eRgba32, + /** BGRA, 8 bits x 4 */ + eBgra32, + /** Monochrome, 12 bits */ + eMono12Packed, + /** Bayer-color, 12 bits, packed */ + eBayer12Packed + } + + /** + * Bayer pattern. Applicable only when a Bayer-color camera is sending raw bayer data. + */ + public enum tBayerPattern { + + /** First line RGRG, second line GBGB... */ + eRGGB, // + /** First line GBGB, second line RGRG... */ + eGBRG, // + /** First line GRGR, second line BGBG... */ + eGRBG, // + /** First line BGBG, second line GRGR.. */ + eBGGR, // . + + } + + /** + * Object passed to QueueFrame() + */ + public static class tFrame { + + //----- In ----- + + /** Your image buffer */ + public ByteBuffer ImageBuffer; + /** Your buffer to capture associated header & trailer data for this image. */ + public ByteBuffer AncillaryBuffer; + + //----- In/Out ----- + + /** Array of objects for your own usage */ + public Object[] Contexts; + + //----- Out ----- + + /** Status of this frame */ + public tError Status; + /** Image size, in bytes */ + public long ImageSize; + /** Ancillary data size, in bytes */ + public long AncillarySize; + /** Image width */ + public long Width; + /** Image height */ + public long Height; + /** Start of readout region (left) */ + public long RegionX; + /** Start of readout region (top) */ + public long RegionY; + /** Image format */ + public tImageFormat Format; + /** Number of significant bits */ + public int BitDepth; + /** Bayer pattern, if bayer format */ + public tBayerPattern BayerPattern; + /** Rolling frame counter */ + public long FrameCount; + /** Time stamp, lower 32-bits */ + public long TimestampLo; + /** Time stamp, upper 32-bits */ + public long TimestampHi; + + private long CachedFrame; // used internally, do NOT use + + public tFrame() {ImageBuffer = null;AncillaryBuffer = null;CachedFrame = 0;} + + } + + /** + * Frame listener interface + */ + public static interface FrameListener { + + /** + * The method is called by the API when a frame is been returned from the API + * + * @param tFrame Frame, frame object + */ + public void onFrameEvent(tFrame Frame); + + } + + /** + * Infinite time-out value + */ + public static final long Infinite = 0xFFFFFFFF; + + //----- Attributes ------------------------------------------------------------ + + /** + * Attribute data type supported + */ + public static enum tDatatype { + + eUnknown, + eCommand, + eRaw, + eString, + eEnum, + eUint32, + eFloat32, + eInt64, + eBoolean + + } + + /** + * Attribute flags type + */ + public static class tAttributeFlags { + + /** Read access is permitted */ + public static final int eRead = 0x01; + /** Write access is permitted */ + public static final int eWrite = 0x02; + /** The camera may change the value any time */ + public static final int eVolatile = 0x04; + /** Value is read only and never changes */ + public static final int eConst = 0x08; + + } + + /** + * Attribute information type + */ + public static class tAttributeInfo { + + /** Data type */ + public tDatatype Datatype; + /** Combination of tAttributeFlags */ + public int Flags; + /** Advanced: see documentation */ + public String Category; + /** Advanced: see documentation */ + public String Impact; + + public tAttributeInfo() {} + } + + /** + * Structure holding a list of string + */ + public static class tStringsList { + + /** Array of String object */ + public String Array[]; + /** Number of Object in the array */ + public int Count; + + public tStringsList() {Count = 0;} + } + + /** + * Value range of an Uint32 attribute + */ + public static class tRangeUint32 { + + /** Minimum value */ + public long Min; + /** Maximum value */ + public long Max; + + public tRangeUint32() {Min = Max = 0;} + } + + /** + * Value range of an Int64 attribute + */ + public static class tRangeInt64 { + + /** Minimum value */ + public long Min; + /** Maximum value */ + public long Max; + + public tRangeInt64() {Min = Max = 0;} + } + + /** + * Value range of an Float32 attribute + */ + public static class tRangeFloat32 { + + /** Minimum value */ + public float Min; + /** Maximum value */ + public float Max; + + public tRangeFloat32() {Min = Max = 0;} + } + + /** + * Value of a Float32 attribute + */ + public static class tFloat32 + { + /** Value */ + public float Value; + + public tFloat32() {Value = 0;} + public tFloat32(float Number) {Value = Number;} + + } + + /** + * Value of a Uint32 attribute + */ + public static class tUint32 + { + /** Value */ + public long Value; + + public tUint32() {Value = 0;} + public tUint32(long Number) {Value = Number;} + + } + + /** + * Value of a Int64 attribute + */ + public static class tInt64 + { + /** Value */ + public long Value; + + public tInt64() {Value = 0;} + public tInt64(long Number) {Value = Number;} + + } + + /** + * Value of a Boolean attribute + */ + public static class tBoolean + { + /** Value */ + public boolean Value; + + public tBoolean() {Value = false;} + public tBoolean(boolean Number) {Value = Number;} + + } + + /** + * Value of a String attribute + */ + public static class tString + { + /** Value */ + public String Value; + + public tString() {}; + } + + + //----- API Version ----------------------------------------------------------- + + /** + * Retrieve the version number of PvAPI. This function can be called at any time, + * including before the API is initialised. + * + * @param tVersion Version, version number (output) + */ + public static native void Version(tVersion Version); + + //----- API Initialization ---------------------------------------------------- + + /** + * Initialise the PvApi module. This must be called before any other Pv method is run. + * + * @return eErrSuccess, no error
+ * eErrResources, resources requested from the OS were not available
+ * eErrInternalFault, an internal fault occurred + */ + public static native tError Initialize(); + + /** + * Initialise the PvApi module but ask it to not send discovery broadcast. + * This must be called before any other Pv method is run. + * + * @return eErrSuccess, no error
+ * eErrResources, resources requested from the OS were not available
+ * eErrInternalFault, an internal fault occurred + */ + public static native tError InitializeNoDiscovery(); + + /** + * Uninitialise the API module. This will free some resources, and shut down + * network activity if applicable. + * + */ + public static native void UnInitialize(); + + //----- Interface-Link Listener ----------------------------------------------- + + /** + * Register a listener object for notification of link events + * The oject's method is called from a thread within PvAPI. The calls + * are sequenced; i.e. they will not be called simultaneously. + * + * Use LinkListenerUnRegister() to stop receiving callbacks. + * + * @param LinkListener Listener, listener object + * + * @return eErrSuccess, no error
+ * eErrResources, resources requested from the OS were not available + * eErrBadSequence, API isn't initialised + */ + public static native tError LinkListenerRegister(LinkListener Listener); + + /** + * Unregister a listener object for link events notifications. + * + * @param LinkListener Listener, listener object + * + * @return eErrSuccess, no error
+ * eErrNotFound, registered listener was not found
+ * eErrResources, resources requested from the OS were not available
+ * eErrBadSequence, API isn't initialised + */ + public static native tError LinkListenerUnRegister(LinkListener Listener); + + //----- Camera Enumeration & Information -------------------------------------- + + /** + * List all the cameras currently visible to PvAPI + * + * @param tCameraInfoEx[] List, an array of tCameraInfo to be filled + * @param int Length, the maximum number of element the array can accept + * + * @return number of camera listed + */ + public static native int CameraListEx(tCameraInfoEx[] List,int Length); + + /** + * List all the cameras currently visible to PvAPI (deprecated) + * + * @param tCameraInfo[] List, an array of tCameraInfo to be filled + * @param int Length, the maximum number of element the array can accept + * + * @return number of camera listed + */ + public static native int CameraList(tCameraInfo[] List,int Length); + + /** + * List all the cameras currently inaccessable by PvAPI. This lists + * the Ethernet cameras which are connected to the local Ethernet + * network, but are on a different subnet. + * + * @param tCameraInfoEx[] List, an array of tCameraInfo to be filled + * @param int Length, the maximum number of element the array can accept + * + * @return number of camera listed + */ + public static native int CameraListUnreachableEx(tCameraInfoEx[] List,int Length); + + /** + * List all the cameras currently inaccessable by PvAPI. This lists + * the Ethernet cameras which are connected to the local Ethernet + * network, but are on a different subnet. (deprecated) + * + * @param tCameraInfo[] List, an array of tCameraInfo to be filled + * @param int Length, the maximum number of element the array can accept + * + * @return number of camera listed + */ + public static native int CameraListUnreachable(tCameraInfo[] List,int Length); + + /** + * Number of cameras visible to PvAPI (at the time of the call). + * Does not include unreachable cameras. + * + * @return The number of cameras detected + */ + public static native int CameraCount(); + + /** + * Retrieve information on a given camera + * + * @param long UniqueId, Unique ID of the camera + * @param tCameraInfoEx Info, Camera info will be copied in this object + * + * @return eErrSuccess, no error
+ * eErrNotFound, the camera was not found (unplugged)
+ * eErrUnplugged, the camera was found but unplugged during the function call
+ * eErrResources, resources requested from the OS were not available
+ * eErrInternalFault, an internal fault occurred
+ * eErrBadSequence, API isn't initialised + */ + public static native tError CameraInfoEx(long UniqueId,tCameraInfoEx Info); + + /** + * Retrieve information on a given camera (deprecated) + * + * @param long UniqueId, Unique ID of the camera + * @param tCameraInfo Info, Camera info will be copied in this object + * + * @return eErrSuccess, no error
+ * eErrNotFound, the camera was not found (unplugged)
+ * eErrUnplugged, the camera was found but unplugged during the function call
+ * eErrResources, resources requested from the OS were not available
+ * eErrInternalFault, an internal fault occurred
+ * eErrBadSequence, API isn't initialised + */ + public static native tError CameraInfo(long UniqueId,tCameraInfo Info); + + /** + * Retrieve information on a camera, by IP address. This function is required + * if the Ethernet camera is not on the local Ethernet network.

+ * The specified camera may not be visible to CameraList(), it might be on a + * different ethernet network. In this case, communication with the camera is + * routed to the local gateway. + * + * @param byte[] Address, IP address of camera, in network byte order. + * @param tCameraInfoEx Info, Camera info will be copied in this object + * + * @return eErrSuccess, no error
+ * eErrNotFound, the camera was not found
+ * eErrUnplugged, the camera was found but unplugged during the function call
+ * eErrResources, resources requested from the OS were not available
+ * eErrInternalFault, an internal fault occurred
+ * eErrBadSequence, API isn't initialised + */ + public static native tError CameraInfoByAddrEx(byte[] Address,tCameraInfoEx Info); + + /** + * Retrieve information on a camera, by IP address. This function is required + * if the Ethernet camera is not on the local Ethernet network.

+ * The specified camera may not be visible to CameraList(), it might be on a + * different ethernet network. In this case, communication with the camera is + * routed to the local gateway. (deprecated) + * + * @param byte[] Address, IP address of camera, in network byte order. + * @param tCameraInfo Info, Camera info will be copied in this object + * + * @return eErrSuccess, no error
+ * eErrNotFound, the camera was not found
+ * eErrUnplugged, the camera was found but unplugged during the function call
+ * eErrResources, resources requested from the OS were not available
+ * eErrInternalFault, an internal fault occurred
+ * eErrBadSequence, API isn't initialised + */ + public static native tError CameraInfoByAddr(byte[] Address,tCameraInfo Info); + + /** + * Get the IP settings for an Ethernet camera. This command will work + * for all cameras on the local Ethernet network, including "unreachable" cameras. + * + * @param long UniqueId, Unique ID of the camera + * @param tIpSettings Settings, IP settings will be copied in this object + * + * @return eErrSuccess, no error
+ * eErrNotFound, the camera was not found
+ * eErrResources, resources requested from the OS were not available
+ * eErrInternalFault, an internal fault occurred
+ * eErrBadSequence, API isn't initialised + */ + public static native tError CameraIpSettingsGet(long UniqueId,tIpSettings Settings); + + + /** + * Change the IP settings for an Ethernet camera. This command will work for all + * cameras on the local Ethernet network, including "unreachable" cameras.

+ * This method will fail if any application on any host has opened the camera. + * + * @param long UniqueId, Unique ID of the camera + * @param tIpSettings Settings, IP settings will be copied from this object + * + * @return eErrSuccess, no error
+ * eErrNotFound, the camera was not found
+ * eErrResources, resources requested from the OS were not available
+ * eErrInternalFault, an internal fault occurred
+ * eErrBadSequence, API isn't initialised + */ + public static native tError CameraIpSettingsChange(long UniqueId,tIpSettings Settings); + + //----- Opening & Closing ----------------------------------------------------- + + /** + * Open the specified camera. This method must be called before you can control the + * camera. If eErrSuccess is returned, you must eventually call CameraClose().

+ * + * Alternatively, under special circumstances, you might open an Ethernet + * camera with CameraOpenByAddr(). + * + * @param long UniqueId, Unique ID of the camera + * @param int AccessFlag, Access flag {monitor, master} + * @param tHandle Handle, Handle to the opened camera is returned here + * + * @return eErrSuccess, no error
+ * eErrAccessDenied, the camera couldn't be open in the requested mode
+ * eErrNotFound, the camera was not found (unplugged)
+ * eErrUnplugged, the camera was found but unplugged during the call
+ * eErrResources, resources requested from the OS were not available
+ * eErrInternalFault, an internal fault occurred
+ * eErrBadSequence, API isn't initialised or camera is already open + */ + public static native tError CameraOpen(long UniqueId,int AccessFlag,tHandle Handle); + + /** + * Open the specified camera, by IP address. This function is required, in place + * of PvCameraOpen(), if the ethernet camera is not on the local ethernet network.

+ * + * + * @param byte[] Address, IP address of camera, in network byte order. + * @param int AccessFlag, Access flag {monitor, master} + * @param tHandle Handle, Handle to the opened camera is returned here + * + * @return eErrSuccess, no error
+ * eErrAccessDenied, the camera couldn't be open in the requested mode
+ * eErrNotFound, the camera was not found (unplugged)
+ * eErrUnplugged, the camera was found but unplugged during the call
+ * eErrResources, resources requested from the OS were not available
+ * eErrInternalFault, an internal fault occurred
+ * eErrBadSequence, API isn't initialised or camera is already open + */ + public static native tError CameraOpenByAddr(byte[] Address,int AccessFlag,tHandle Handle); + + /** + * Close the specified camera. + * + * @param tHandle Handle, Handle to the opened camera + * + * @return eErrSuccess, no error
+ * eErrBadHandle , handle is bad
+ * eErrBadSequence, API isn't initialised + */ + public static native tError CameraClose(tHandle Handle); + + //----- Image Capture --------------------------------------------------------- + + /** + * Setup the camera interface for image transfer. This does not necessarily + * start acquisition.

+ * + * CaptureStart() must be run before CaptureQueueFrame() is allowed. But + * the camera will not acquire images before the "AcquisitionMode" attribute is + * set to a non-idle mode. + * + * @param tHandle Handle, Handle to the opened camera + * + * @return eErrSuccess, no error
+ * eErrBadHandle , handle is bad
+ * eErrUnplugged, the camera has been unplugged
+ * eErrResources, resources requested from the OS were not available
+ * eErrInternalFault, an internal fault occurred
+ * eErrBadSequence, API isn't initialised or capture already started + */ + public static native tError CaptureStart(tHandle Camera); + + /** + * Disable the image transfer mechanism.

+ * + * This cannot be called until the frame queue is empty. + * + * @param tHandle Handle, Handle to the opened camera + * + * @return eErrSuccess, no error
+ * eErrBadHandle , handle is bad
+ * eErrUnplugged, the camera has been unplugged
+ * eErrInternalFault, an internal fault occurred
+ * eErrBadSequence, API isn't initialised or capture already stopped + */ + public static native tError CaptureEnd(tHandle Camera); + + /** + * Check to see if a camera interface is ready to transfer images. I.e. has + * CaptureStart() been called? + * + * @param tHandle Handle, Handle to the opened camera + * + * @return true if the camera interface is ready to transfer images, false otherwise + */ + public static native boolean CaptureQuery(tHandle Camera); + + /** + * Queue a frame object for image capture.

+ * + * This function returns immediately. If eErrSuccess is returned, the frame + * will remain in the queue until it is complete, or aborted due to an error or + * a call to CaptureQueueClear(). + * + * Frames are completed (or aborted) in the order they are queued. + * + * You can specify a listener object to be notified when the frame is complete, + * or you can use CaptureWaitForFrameDone() to block until the frame is complete. + * + * When the frame listener is been notified, the tFrame object is no longer in + * use and you are free to do with it as you please (for example, reuse or + * deallocation.) + * + * Each frame on the queue must be a unique tFrame data structure. + * + * @param tHandle Camera, Handle to the camera + * @param tFrame pFrame, Frame to queue + * @param FrameListener Listener, Listener object to be notified when the frame is done; + * may be null if there is no listener + * + * @return eErrSuccess, no error
+ * eErrBadHandle, the handle of the camera is invalid
+ * eErrUnplugged, the camera has been unplugged
+ * eErrQueueFull, the frame queue is full
+ * eErrResources, resources requested from the OS were not available
+ * eErrInternalFault, an internal fault occurred
+ * eErrBadSequence, API isn't initialised or capture not started + */ + public static native tError CaptureQueueFrame(tHandle Camera,tFrame Frame,FrameListener Listener); + + /** + * Wait for a queued frame to have been captured

+ * + * This function cannot be called from the frame listener. + * + * When this function returns, the frame object is no longer in use and you + * are free to do with it as you please (for example, reuse or deallocation). + * + * If you are using the frame object notification: this method might return first, + * or the listener might be notified first. + * + * If the specified frame is not on the queue, this function returns + * eErrSuccess, since we do not know if the frame just left the queue. + * + * @param tHandle Handle, Handle to the opened camera + * @param tFrame pFrame, Frame to wait upon + * @param long Timeout, Wait timeout (in milliseconds); use Pv.Infinite for no timeout + * + * @return eErrSuccess, no error
+ * eErrBadHandle, the handle of the camera is invalid
+ * eErrTimeout, timeout while waiting for the frame + * eErrInternalFault, an internal fault occurred + * eErrBadSequence, API isn't initialised + */ + public static native tError CaptureWaitForFrameDone(tHandle Camera,tFrame Frame,long Timeout); + + /** + * Empty the frame queue.

+ * + * Queued frames are returned with status eErrCancelled. + * + * CaptureQueueClear() cannot be called from the frame listener. + * + * When this function returns, no more frames are left on the queue and you + * will not receive another listener notification. + * + * @param tHandle Handle, Handle to the opened camera + * + * @return eErrSuccess, no error
+ * eErrBadHandle , handle is bad
+ * eErrInternalFault, an internal fault occurred
+ * eErrBadSequence, API isn't initialised or capture already stopped + */ + public static native tError CaptureQueueClear(tHandle Camera); + + /** + * Determine the maximum packet size supported by the system.

+ * + * The maximum packet size can be limited by the camera, host adapter, and + * Ethernet switch. + * + * CaptureAdjustPacketSize() cannot be run when capture has started. + * + * @param tHandle Handle, Handle to the opened camera + * @param long MaximumPacketSize, Upper limit: the packet size will + * not be set higher than this value. + * + * @return eErrSuccess, no error
+ * eErrBadHandle, the handle of the camera is invalid
+ * eErrUnplugged, the camera has been unplugged
+ * eErrResources, resources requested from the OS were not available
+ * eErrInternalFault, an internal fault occurred
+ * eErrBadSequence, API isn't initialised or capture already started + */ + public static native tError CaptureAdjustPacketSize(tHandle Camera,long MaximumPacketSize); + + //----- Attributes ------------------------------------------------------------ + + /** + * List all the attributes for a given camera. + * + * @param tHandle Handle, Handle to the opened camera + * @param tStringList List, array of attribute label (object must be "allocated") + * + * @return eErrSuccess, no error
+ * eErrBadHandle, the handle of the camera is invalid
+ * eErrUnplugged, the camera has been unplugged
+ * eErrInternalFault, an internal fault occurred
+ * eErrBadSequence, API isn't initialised + */ + public static native tError AttrList(tHandle Handle,tStringsList List); + + /** + * Retrieve information on an camera's attribute + * + * @param tHandle Handle, Handle to the opened camera + * @param String Label, label of the attribute + * @param tAttributeInfo Info, info are copied here (object must be allocated) + * + * @return eErrSuccess, no error
+ * eErrBadHandle, the handle of the camera is invalid
+ * eErrUnplugged, the camera has been unplugged
+ * eErrNotFound, the requested attribute doesn't exist
+ * eErrInternalFault, an internal fault occurred
+ * eErrBadSequence, API isn't initialised + */ + public static native tError AttrInfo(tHandle Handle,String Label,tAttributeInfo Info); + + /** + * Check if an attribute exists for the camera. + * + * @param tHandle Handle, Handle to the opened camera + * @param String Label, label of the attribute + * + * @return eErrSuccess, no error
+ * eErrBadHandle, the handle of the camera is invalid
+ * eErrUnplugged, the camera has been unplugged
+ * eErrNotFound, the requested attribute doesn't exist
+ * eErrInternalFault, an internal fault occurred
+ * eErrBadSequence, API isn't initialised + */ + public static native tError AttrExists(tHandle Handle,String Label); + + /** + * Check if an attribute is available. + * + * @param tHandle Handle, Handle to the opened camera + * @param String Label, label of the attribute + * + * @return eErrSuccess, the attribute is available
+ * eErrUnavailable, the attribute is not available
+ * eErrBadHandle, the handle of the camera is invalid
+ * eErrUnplugged, the camera has been unplugged
+ * eErrNotFound, the requested attribute doesn't exist
+ * eErrInternalFault, an internal fault occurred
+ * eErrBadSequence, API isn't initialised + */ + public static native tError AttrIsAvailable(tHandle Handle,String Label); + + /** + * Check if an attribute's value is valid. + * + * @param tHandle Handle, Handle to the opened camera + * @param String Label, label of the attribute + * + * @return eErrSuccess, the attribute is available
+ * eErrOutOfRange, the attribute is not valid
+ * eErrBadHandle, the handle of the camera is invalid
+ * eErrUnplugged, the camera has been unplugged
+ * eErrOutOfRange, the requested attribute is not valid
+ * eErrNotFound, the requested attribute doesn't exist
+ * eErrInternalFault, an internal fault occurred
+ * eErrBadSequence, API isn't initialised + */ + public static native tError AttrIsValid(tHandle Handle,String Label); + + /** + * Get the enumeration set for an enumerated attribute. The set is returned + * in an array of strings + * + * @param tHandle Handle, Handle to the opened camera + * @param String Label, label of the attribute + * @param tStringList Range, range is copied here (object must be allocated) + * + * @return eErrSuccess, no error
+ * eErrBadHandle, the handle of the camera is invalid
+ * eErrUnplugged, the camera has been unplugged
+ * eErrNotFound, the requested attribute doesn't exist
+ * eErrWrongType, the requested attribute is not of the correct type
+ * eErrInternalFault, an internal fault occurred
+ * eErrBadSequence, API isn't initialised + */ + public static native tError AttrRangeEnum(tHandle Handle,String Label,tStringsList Range); + + /** + * Get the value range for a uint32 attribute. + * + * @param tHandle Handle, Handle to the opened camera + * @param String Label, label of the attribute + * @param tRangeUint32 Range, range is copied here (object must be allocated) + * + * @return eErrSuccess, no error
+ * eErrBadHandle, the handle of the camera is invalid
+ * eErrUnplugged, the camera has been unplugged
+ * eErrNotFound, the requested attribute doesn't exist
+ * eErrWrongType, the requested attribute is not of the correct type
+ * eErrInternalFault, an internal fault occurred
+ * eErrBadSequence, API isn't initialised + */ + public static native tError AttrRangeUint32(tHandle Handle,String Label,tRangeUint32 Range); + + /** + * Get the value range for a int64 attribute. + * + * @param tHandle Handle, Handle to the opened camera + * @param String Label, label of the attribute + * @param tRangeInt64 Range, range is copied here (object must be allocated) + * + * @return eErrSuccess, no error
+ * eErrBadHandle, the handle of the camera is invalid
+ * eErrUnplugged, the camera has been unplugged
+ * eErrNotFound, the requested attribute doesn't exist
+ * eErrWrongType, the requested attribute is not of the correct type
+ * eErrInternalFault, an internal fault occurred
+ * eErrBadSequence, API isn't initialised + */ + public static native tError AttrRangeInt64(tHandle Handle,String Label,tRangeInt64 Range); + + /** + * Get the value range for a float32 attribute. + * + * @param tHandle Handle, Handle to the opened camera + * @param String Label, label of the attribute + * @param tRangeFloat32 Range, range is copied here (object must be allocated) + * + * @return eErrSuccess, no error
+ * eErrBadHandle, the handle of the camera is invalid
+ * eErrUnplugged, the camera has been unplugged
+ * eErrNotFound, the requested attribute doesn't exist
+ * eErrWrongType, the requested attribute is not of the correct type
+ * eErrInternalFault, an internal fault occurred
+ * eErrBadSequence, API isn't initialised + */ + public static native tError AttrRangeFloat32(tHandle Handle,String Label,tRangeFloat32 Range); + + /** + * Run a specific command on the camera + * + * @param tHandle Handle, Handle to the opened camera + * @param String Label, label of the attribute + * @param tRangeFloat32 Range, range is copied here (object must be allocated) + * + * @return eErrSuccess, no error
+ * eErrBadHandle, the handle of the camera is invalid
+ * eErrUnplugged, the camera has been unplugged
+ * eErrNotFound, the requested attribute doesn't exist
+ * eErrWrongType, the requested attribute is not of the correct type
+ * eErrInternalFault, an internal fault occurred
+ * eErrBadSequence, API isn't initialised + */ + public static native tError CommandRun(tHandle Handle,String Label); + + /** + * Get the value of a string attribute. + * + * @param tHandle Handle, Handle to the opened camera + * @param String Label, label of the attribute + * @param tString Value, Attribute's value copied here + * + * @return eErrSuccess, no error
+ * eErrBadHandle, the handle of the camera is invalid
+ * eErrUnplugged, the camera has been unplugged
+ * eErrNotFound, the requested attribute doesn't exist
+ * eErrWrongType, the requested attribute is not of the correct type
+ * eErrInternalFault, an internal fault occurred
+ * eErrBadSequence, API isn't initialised + */ + public static native tError AttrStringGet(tHandle Handle,String Label,tString Value); + + /** + * Set the value of a string attribute. + * + * @param tHandle Handle, Handle to the opened camera + * @param String Label, label of the attribute + * @param String Value, Attribute's value + * + * @return eErrSuccess, no error
+ * eErrBadHandle, the handle of the camera is invalid
+ * eErrUnplugged, the camera has been unplugged
+ * eErrNotFound, the requested attribute doesn't exist
+ * eErrWrongType, the requested attribute is not of the correct type
+ * eErrForbidden, the requested attribute forbid this operation
+ * eErrInternalFault, an internal fault occurred
+ * eErrBadSequence, API isn't initialised + */ + public static native tError AttrStringSet(tHandle Handle,String Label,String Value); + + /** + * Set the value of a string attribute. + * + * @param tHandle Handle, Handle to the opened camera + * @param String Label, label of the attribute + * @param tString Value, Attribute's value + * + * @return eErrSuccess, no error
+ * eErrBadHandle, the handle of the camera is invalid
+ * eErrUnplugged, the camera has been unplugged
+ * eErrNotFound, the requested attribute doesn't exist
+ * eErrWrongType, the requested attribute is not of the correct type
+ * eErrForbidden, the requested attribute forbid this operation
+ * eErrInternalFault, an internal fault occurred
+ * eErrBadSequence, API isn't initialised + */ + public static tError AttrStringSet(tHandle Handle,String Label,tString Value) + { + return AttrStringSet(Handle,Label,Value.Value); + } + + /** + * Get the value of an enumerated attribute. The enumeration value is a string. + * + * @param tHandle Handle, Handle to the opened camera + * @param String Label, label of the attribute + * @param tString Value, Attribute's value copied here + * + * @return eErrSuccess, no error
+ * eErrBadHandle, the handle of the camera is invalid
+ * eErrUnplugged, the camera has been unplugged
+ * eErrNotFound, the requested attribute doesn't exist
+ * eErrWrongType, the requested attribute is not of the correct type
+ * eErrInternalFault, an internal fault occurred
+ * eErrBadSequence, API isn't initialised + */ + public static native tError AttrEnumGet(tHandle Handle,String Label,tString Value); + + /** + * Set the value of an enumerated attribute. The enumeration value is a string. + * + * @param tHandle Handle, Handle to the opened camera + * @param String Label, label of the attribute + * @param String Value, Attribute's value + * + * @return eErrSuccess, no error
+ * eErrBadHandle, the handle of the camera is invalid
+ * eErrUnplugged, the camera has been unplugged
+ * eErrNotFound, the requested attribute doesn't exist
+ * eErrWrongType, the requested attribute is not of the correct type
+ * eErrOutOfRange, the supplied value is out of range
+ * eErrForbidden, the requested attribute forbid this operation
+ * eErrInternalFault, an internal fault occurred
+ * eErrBadSequence, API isn't initialised + */ + public static native tError AttrEnumSet(tHandle Handle,String Label,String Value); + + /** + * Set the value of an enumerated attribute. The enumeration value is a string. + * + * @param tHandle Handle, Handle to the opened camera + * @param String Label, label of the attribute + * @param tString Value, Attribute's value + * + * @return eErrSuccess, no error
+ * eErrBadHandle, the handle of the camera is invalid
+ * eErrUnplugged, the camera has been unplugged
+ * eErrNotFound, the requested attribute doesn't exist
+ * eErrWrongType, the requested attribute is not of the correct type
+ * eErrOutOfRange, the supplied value is out of range + * eErrForbidden, the requested attribute forbid this operation
+ * eErrInternalFault, an internal fault occurred
+ * eErrBadSequence, API isn't initialised + */ + public static tError AttrEnumSet(tHandle Handle,String Label,tString Value) + { + return AttrEnumSet(Handle,Label,Value.Value); + } + + /** + * Get the value of a uint32 attribute. + * + * @param tHandle Handle, Handle to the opened camera + * @param String Label, label of the attribute + * @param tUint32 Value, value is returned here (must be allocated before) + * + * @return eErrSuccess, no error
+ * eErrBadHandle, the handle of the camera is invalid
+ * eErrUnplugged, the camera has been unplugged
+ * eErrNotFound, the requested attribute doesn't exist
+ * eErrWrongType, the requested attribute is not of the correct type
+ * eErrInternalFault, an internal fault occurred
+ * eErrBadSequence, API isn't initialised + */ + public static native tError AttrUint32Get(tHandle Handle,String Label,tUint32 Value); + + /** + * Set the value of a uint32 attribute. + * + * @param tHandle Handle, Handle to the opened camera + * @param String Label, label of the attribute + * @param long Value, Attribute's value + * + * @return eErrSuccess, no error
+ * eErrBadHandle, the handle of the camera is invalid
+ * eErrUnplugged, the camera has been unplugged
+ * eErrNotFound, the requested attribute doesn't exist
+ * eErrWrongType, the requested attribute is not of the correct type
+ * eErrOutOfRange, the supplied value is out of range
+ * eErrForbidden, the requested attribute forbid this operation
+ * eErrInternalFault, an internal fault occurred
+ * eErrBadSequence, API isn't initialised + */ + public static native tError AttrUint32Set(tHandle Handle,String Label,long Value); + + /** + * Set the value of a uint32 attribute. + * + * @param tHandle Handle, Handle to the opened camera + * @param String Label, label of the attribute + * @param tUint32 Value, Attribute's value + * + * @return eErrSuccess, no error
+ * eErrBadHandle, the handle of the camera is invalid
+ * eErrUnplugged, the camera has been unplugged
+ * eErrNotFound, the requested attribute doesn't exist
+ * eErrWrongType, the requested attribute is not of the correct type
+ * eErrOutOfRange, the supplied value is out of range
+ * eErrForbidden, the requested attribute forbid this operation
+ * eErrInternalFault, an internal fault occurred
+ * eErrBadSequence, API isn't initialised + */ + public static tError AttrUint32Set(tHandle Handle,String Label,tUint32 Value) + { + return AttrUint32Set(Handle,Label,Value.Value); + } + + /** + * Get the value of a int64 attribute. + * + * @param tHandle Handle, Handle to the opened camera + * @param String Label, label of the attribute + * @param tInt64 Value, value is returned here (must be allocated before) + * + * @return eErrSuccess, no error
+ * eErrBadHandle, the handle of the camera is invalid
+ * eErrUnplugged, the camera has been unplugged
+ * eErrNotFound, the requested attribute doesn't exist
+ * eErrWrongType, the requested attribute is not of the correct type
+ * eErrInternalFault, an internal fault occurred
+ * eErrBadSequence, API isn't initialised + */ + public static native tError AttrInt64Get(tHandle Handle,String Label,tInt64 Value); + + /** + * Set the value of a int64 attribute. + * + * @param tHandle Handle, Handle to the opened camera + * @param String Label, label of the attribute + * @param long Value, Attribute's value + * + * @return eErrSuccess, no error
+ * eErrBadHandle, the handle of the camera is invalid
+ * eErrUnplugged, the camera has been unplugged
+ * eErrNotFound, the requested attribute doesn't exist
+ * eErrWrongType, the requested attribute is not of the correct type
+ * eErrOutOfRange, the supplied value is out of range
+ * eErrForbidden, the requested attribute forbid this operation
+ * eErrInternalFault, an internal fault occurred
+ * eErrBadSequence, API isn't initialised + */ + public static native tError AttrInt64Set(tHandle Handle,String Label,long Value); + + /** + * Set the value of an int64 attribute. + * + * @param tHandle Handle, Handle to the opened camera + * @param String Label, label of the attribute + * @param tUint32 Value, Attribute's value + * + * @return eErrSuccess, no error
+ * eErrBadHandle, the handle of the camera is invalid
+ * eErrUnplugged, the camera has been unplugged
+ * eErrNotFound, the requested attribute doesn't exist
+ * eErrWrongType, the requested attribute is not of the correct type
+ * eErrOutOfRange, the supplied value is out of range
+ * eErrForbidden, the requested attribute forbid this operation
+ * eErrInternalFault, an internal fault occurred
+ * eErrBadSequence, API isn't initialised + */ + public static tError AttrInt64Set(tHandle Handle,String Label,tInt64 Value) + { + return AttrInt64Set(Handle,Label,Value.Value); + } + + /** + * Get the value of a float32 attribute. + * + * @param tHandle Handle, Handle to the opened camera + * @param String Label, label of the attribute + * @param tFloat32 Value, value is returned here (must be allocated before) + * + * @return eErrSuccess, no error
+ * eErrBadHandle, the handle of the camera is invalid
+ * eErrUnplugged, the camera has been unplugged
+ * eErrNotFound, the requested attribute doesn't exist
+ * eErrWrongType, the requested attribute is not of the correct type
+ * eErrInternalFault, an internal fault occurred
+ * eErrBadSequence, API isn't initialised + */ + public static native tError AttrFloat32Get(tHandle Handle,String Label,tFloat32 Value); + + /** + * Set the value of a float32 attribute. + * + * @param tHandle Handle, Handle to the opened camera + * @param String Label, label of the attribute + * @param float Value, Attribute's value + * + * @return eErrSuccess, no error
+ * eErrBadHandle, the handle of the camera is invalid
+ * eErrUnplugged, the camera has been unplugged
+ * eErrNotFound, the requested attribute doesn't exist
+ * eErrWrongType, the requested attribute is not of the correct type
+ * eErrOutOfRange, the supplied value is out of range
+ * eErrForbidden, the requested attribute forbid this operation
+ * eErrInternalFault, an internal fault occurred
+ * eErrBadSequence, API isn't initialised + */ + public static native tError AttrFloat32Set(tHandle Handle,String Label,float Value); + + /** + * Set the value of a float32 attribute. + * + * @param tHandle Handle, Handle to the opened camera + * @param String Label, label of the attribute + * @param tFloat32 Value, Attribute's value + * + * @return eErrSuccess, no error
+ * eErrBadHandle, the handle of the camera is invalid
+ * eErrUnplugged, the camera has been unplugged
+ * eErrNotFound, the requested attribute doesn't exist
+ * eErrWrongType, the requested attribute is not of the correct type
+ * eErrOutOfRange, the supplied value is out of range
+ * eErrForbidden, the requested attribute forbid this operation
+ * eErrInternalFault, an internal fault occurred
+ * eErrBadSequence, API isn't initialised + */ + public static tError AttrFloat32Set(tHandle Handle,String Label,tFloat32 Value) + { + return AttrFloat32Set(Handle,Label,Value.Value); + } + + /** + * Get the value of a boolean attribute. + * + * @param tHandle Handle, Handle to the opened camera + * @param String Label, label of the attribute + * @param tBoolean Value, value is returned here (must be allocated before) + * + * @return eErrSuccess, no error
+ * eErrBadHandle, the handle of the camera is invalid
+ * eErrUnplugged, the camera has been unplugged
+ * eErrNotFound, the requested attribute doesn't exist
+ * eErrWrongType, the requested attribute is not of the correct type
+ * eErrInternalFault, an internal fault occurred
+ * eErrBadSequence, API isn't initialised + */ + public static native tError AttrBooleanGet(tHandle Handle,String Label,tBoolean Value); + + /** + * Set the value of a boolean attribute. + * + * @param tHandle Handle, Handle to the opened camera + * @param String Label, label of the attribute + * @param boolean Value, Attribute's value + * + * @return eErrSuccess, no error
+ * eErrBadHandle, the handle of the camera is invalid
+ * eErrUnplugged, the camera has been unplugged
+ * eErrNotFound, the requested attribute doesn't exist
+ * eErrWrongType, the requested attribute is not of the correct type
+ * eErrOutOfRange, the supplied value is out of range
+ * eErrForbidden, the requested attribute forbid this operation
+ * eErrInternalFault, an internal fault occurred
+ * eErrBadSequence, API isn't initialised + */ + public static native tError AttrBooleanSet(tHandle Handle,String Label,boolean Value); + + /** + * Set the value of an boolean attribute. + * + * @param tHandle Handle, Handle to the opened camera + * @param String Label, label of the attribute + * @param tBoolean Value, Attribute's value + * + * @return eErrSuccess, no error
+ * eErrBadHandle, the handle of the camera is invalid
+ * eErrUnplugged, the camera has been unplugged
+ * eErrNotFound, the requested attribute doesn't exist
+ * eErrWrongType, the requested attribute is not of the correct type
+ * eErrOutOfRange, the supplied value is out of range
+ * eErrForbidden, the requested attribute forbid this operation
+ * eErrInternalFault, an internal fault occurred
+ * eErrBadSequence, API isn't initialised + */ + public static tError AttrBooleanSet(tHandle Handle,String Label,tBoolean Value) + { + return AttrBooleanSet(Handle,Label,Value.Value); + } + + //----- Register access ------------------------------------------------------- + + /** + * Read the values of a set of camera's registers + * + * @param tHandle Handle, Handle to the opened camera + * @param long NumReads, number of registers to be read + * @param long[] AddressArray, array of register addresses + * @param long[] DataArray, values are returned here (one per register, must be allocated before) + * @param tUint32 NumComplete, number of registers actually read + * + * @return eErrSuccess, no error
+ * eErrBadHandle, the handle of the camera is invalid
+ * eErrUnplugged, the camera has been unplugged
+ * eBadParameter, NumReads is incorrect
+ * eAccessDenied, read is not permitted (or register does not exist + */ + public static native tError RegisterRead(tHandle Handle,long NumReads,long[] AddressArray,long[] DataArray,tUint32 NumComplete); + + /** + * Write the values of a set of camera's registers + * + * @param tHandle Handle, Handle to the opened camera + * @param long NumWrites, number of registers to be wrote + * @param long[] AddressArray, array of register addresses + * @param long[] DataArray, values to be wrote (one per register) + * @param tUint32 NumComplete, number of registers actually wrote + * + * @return eErrSuccess, no error
+ * eErrBadHandle, the handle of the camera is invalid
+ * eErrUnplugged, the camera has been unplugged
+ * eBadParameter, NumWrites is incorrect
+ * eAccessDenied, write is not permitted (or register does not exist) + */ + public static native tError RegisterWrite(tHandle Handle,long NumWrites,long[] AddressArray,long[] DataArray,tUint32 NumComplete); + + //----- Utility --------------------------------------------------------------- + + /** + * Convert a native frame into an existing BGR buffer (TYPE_3BYTE_BGR) + * + * @param tFrame Frame, captured frame to be converted + * @param ByteBuffer Buffer, buffer to write in + * + * @return eErrSuccess, no error
+ * eBufferTooSmall, buffer is too small + */ + public static native tError FrameToBGRBuffer(tFrame Frame,ByteBuffer Buffer); + + // load the Native library + static { + + System.loadLibrary("PvJNI"); + + } + +}