1 /* 2 * Copyright (c) 2006 Stiftung Deutsches Elektronen-Synchroton, 3 * Member of the Helmholtz Association, (DESY), HAMBURG, GERMANY. 4 * 5 * THIS SOFTWARE IS PROVIDED UNDER THIS LICENSE ON AN "../AS IS" BASIS. 6 * WITHOUT WARRANTY OF ANY KIND, EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED 7 * TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR PARTICULAR PURPOSE AND 8 * NON-INFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE 9 * FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, 10 * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR 11 * THE USE OR OTHER DEALINGS IN THE SOFTWARE. SHOULD THE SOFTWARE PROVE DEFECTIVE 12 * IN ANY RESPECT, THE USER ASSUMES THE COST OF ANY NECESSARY SERVICING, REPAIR OR 13 * CORRECTION. THIS DISCLAIMER OF WARRANTY CONSTITUTES AN ESSENTIAL PART OF THIS LICENSE. 14 * NO USE OF ANY SOFTWARE IS AUTHORIZED HEREUNDER EXCEPT UNDER THIS DISCLAIMER. 15 * DESY HAS NO OBLIGATION TO PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, 16 * OR MODIFICATIONS. 17 * THE FULL LICENSE SPECIFYING FOR THE SOFTWARE THE REDISTRIBUTION, MODIFICATION, 18 * USAGE AND OTHER RIGHTS AND OBLIGATIONS IS INCLUDED WITH THE DISTRIBUTION OF THIS 19 * PROJECT IN THE FILE LICENSE.HTML. IF THE LICENSE IS NOT INCLUDED YOU MAY FIND A COPY 20 * AT HTTP://WWW.DESY.DE/LEGAL/LICENSE.HTM 21 */ 22 23 package de.desy.acop.demo.example; 24 25 import java.beans.PropertyVetoException; 26 27 import com.cosylab.util.CommonException; 28 29 import de.desy.acop.transport.AccessMode; 30 import de.desy.acop.transport.ConnectionParameters; 31 import de.desy.acop.video.AcopVideo; 32 33 //mdavid: added 34 import de.desy.acop.video.displayer.ColorMap; 35 import de.desy.acop.video.displayer.OverlayState; 36 import de.desy.acop.video.displayer.ImageCLUT; 37 38 //mdavid: commented 39 //import de.desy.video.sw.ImageDisplayer.ColorMap; 40 //import de.desy.video.sw.ImageDisplayer.OverlayState; 41 42 public class VideoExample { 43 44 public static void main(String[] args) { 45 46 // How to connect video bean to a remote property? 47 // First we create an instance of the AcopVideo object. 48 AcopVideo video = new AcopVideo(); 49 50 // We require ConnectionParameters which describe the remote property 51 ConnectionParameters parameters = new ConnectionParameters("TINE", "context", "server", "device", "property", AccessMode.POLL, 1000); 52 53 // These parameters describe a remote property 'context/server/device/property' 54 // in the TINE control system that delivers either a VSv2 video image blob or a 55 // VSv3 CF_IMAGE type back. 56 // 57 // Examples for VSv2: 58 // 59 // (1) scheduled transfer 60 // context = "PITZ" // usually general context of facility 61 // server = "ZNPPITZFG1F" // usually server dns name in upper case plus "F" 62 // device = "device_0" // always "device_0" for VSv2 63 // property = "FRAME.GET" // scheduled property 64 // AccessMode = AccessMode.POLL // constant monitoring 65 // AccessRate = 1000 ms // contract refresh time on scheduling 66 // 67 // Note: This is a scheduled transfer mode, so any image should be seen even if the 68 // images are send out with a faster rate than the accessrate is. It is 69 // the recommended mode for live viewing. 70 // 71 // (2) nonscheduled transfer 72 // 73 // context = "PITZ" // usually general context of facility 74 // server = "ZNPPITZFG1F" // usually server dns name in upper case plus "F" 75 // device = "device_0" // always "device_0" for VSv2 76 // property = "NONSCHED.GET" // current video image-property 77 // AccessMode = AccessMode.POLL // constant monitoring 78 // AccessRate = 1000 ms // update data every second 79 // 80 // Note: This is a NONscheduled transfer mode, so the maximum image update rate is 81 // one frame per second according to the AccessRate. 82 // 83 // 84 // Examples for VSv3: 85 // 86 // (1) scheduled transfer 87 // context = "PITZ" // usually general context of facility 88 // server = "SGP_PRSGE1" // TINE server name 89 // device = "Output" // usually "Output" is used for general output 90 // property = "Frame.Sched" // scheduled property 91 // AccessMode = AccessMode.POLL // constant monitoring 92 // AccessRate = 1000 ms // contract refresh time on scheduling 93 // 94 // Note: This is a scheduled transfer mode, so any image should be seen even if the 95 // images are send out with a faster rate than the accessrate is. It is 96 // the recommended mode for live viewing. 97 // 98 // (2) nonscheduled transfer 99 // 100 // context = "PITZ" // usually general context of facility 101 // server = "SGP_PRSGR1" // TINE server name 102 // device = "Output" // usually "Output" is used for general output 103 // property = "Frame" // current video image-property (non-scheduled) 104 // AccessMode = AccessMode.POLL // constant monitoring 105 // AccessRate = 1000 ms // update data every second 106 // 107 // Note: These parameters will use a NONscheduled transfer mode, so the maximum 108 // image update rate is one frame per second according to the AccessRate. 109 // 110 111 // Parameters are then attached to the video bean. 112 try { 113 video.setConnectionParameters(parameters); 114 } catch (CommonException e) { 115 e.printStackTrace(); 116 } catch (PropertyVetoException e) { 117 e.printStackTrace(); 118 } 119 120 // Due to heavy-duty task the connection is not established automatically. Instead 121 // the user has to invoke the start method to establish a connection and 122 // start image rendering 123 124 video.start(); 125 126 // If no exception occurred, video bean should now show images from remote peer. 127 128 // mdavid: commented 129 // // Other properties of the video can also simply be adjusted by calling the 130 // // appropriate setter methods. Let's say that we want to display image 131 // // metaproperties (connection data, width, height, ...) as overlay (like 132 // // an on-screen-display). In this case one has to enable the overlay 133 // // 134 // // For general information on False colours, please refer to user documentation. 135 // // 136 // video.setOverlayEnabled(true); 137 138 // to enable the overlay information 139 video.getImageDisplayer().setOverlayState(OverlayState.ON); // mdavid 140 141 // 142 // We can also change the color map of the image. There are several different 143 // type we can choose from: 144 // ColorMap.GRAYSCALE - basic linear gray scaling like B/W TV 145 // ColorMap.JET - MATLAB jet false colour 146 // ColorMap.PITZ - a False colour table invented at PITZ 1 147 // 148 // For general information on False colours, please refer to user documentation. 149 // 150 // video.getImageDisplayer().setColorMap(ColorMap.JET); // mdavid: changed 151 video.getImageDisplayer().setCLUT(new ImageCLUT(ColorMap.JET, new int[]{8})); // mdavid: changed 152 153 // 154 // Similarly we can enable AOIZoom of the image 155 // 156 // For general information on AOI zooming, please refer to user documentation. 157 // 158 video.getImageDisplayer().setAOIZoom(true); 159 160 // 161 // Activates histogram equalisation (aka normalisation, aka contrast enhancement) 162 // of the image. This can increase recognizability by eye significantly. 163 // 164 // For general information on Histogram Equalisation, please refer to user 165 // documentation. 166 // 167 video.getImageDisplayer().setHistogramEqualisation(true); 168 169 // 170 // Activates maintaining of aspect ratio of the displayed images. So width and height 171 // are kept in relation to the original scene. 172 // 173 // For general information on Aspect ratio, please refer to user 174 // documentation. 175 // 176 video.getImageDisplayer().setKeepAspectRatio(true); 177 178 // similar to most of the above, one can check the current setting of properties 179 // by calling 180 181 if (video.getImageDisplayer().isHistogramEqualisation() == false) 182 System.out.println("Histogram equalisation is not activated."); 183 184 if (video.getImageDisplayer().isKeepAspectRatio() == false) 185 System.out.println("Source scene aspect ratio is not maintained."); 186 187 if (video.getImageDisplayer().isAOIZoom() == false) 188 System.out.println("AOI is not zoomed. If there is an AOI, it should be " + "seen as black frame surrounding the image."); 189 190 // if (video.isOverlayEnabled() == false) // mdavid: commented 191 // System.out.println("On-Screen-Display is currently not shown."); 192 193 System.out.println("On-Screen-Display state is: " + video.getImageDisplayer().getOverlayState()); // mdavid: added 194 195 // if (video.getImageDisplayer().getColorMap() == ColorMap.JET) // mdavid: changed 196 if (video.getImageDisplayer().getCLUT().getColorMap() == ColorMap.JET) // mdavid: changed 197 System.out.println("MATLAB JET False Colour is used on greyscale displaying."); 198 199 // 200 // on special event or shutdown, one may stops an active, running transfer 201 // (which was activated before by start() method) 202 // 203 video.stop(); 204 205 // 206 // saves the currently displayed image to colour png file, saves additional 207 // image metainformation as text file (dump of image header) 208 // 209 // any image enhancement option (like false colour mode, normalisation) will be 210 // seen also in the png file (WYSIWYYG) 211 // 212 if (video.getImageDisplayer().saveAsPNGImage("test.png") == false) { 213 System.out.println("Could not save image (plus metadata) to test.png and test.txt"); 214 } 215 216 } 217 }