Search in sources :

Example 21 with Image

use of com.google.cloud.vision.v1p3beta1.Image in project ovirt-engine by oVirt.

the class OpenStackImageProviderProxy method getAllImagesAsRepoImages.

public List<RepoImage> getAllImagesAsRepoImages(Integer listSize, Integer totalListSize) {
    ArrayList<RepoImage> repoImages = new ArrayList<>();
    long currentTime = System.currentTimeMillis();
    Images images = null;
    do {
        OpenStackRequest<Images> listRequest = getClient().images().list(true).queryParam("limit", listSize).queryParam("sort_key", "name").queryParam("sort_dir", "asc");
        if (images != null) {
            listRequest.queryParam("marker", images.getList().get(images.getList().size() - 1).getId());
        }
        images = listRequest.execute();
        for (Image glanceImage : images) {
            RepoImage repoImage = imageToRepoImage(glanceImage);
            repoImage.setLastRefreshed(currentTime);
            repoImages.add(repoImage);
        }
    } while (images.getList().size() >= listSize && totalListSize != null && repoImages.size() < totalListSize);
    return repoImages;
}
Also used : RepoImage(org.ovirt.engine.core.common.businessentities.storage.RepoImage) Images(com.woorea.openstack.glance.model.v2.Images) ArrayList(java.util.ArrayList) DiskImage(org.ovirt.engine.core.common.businessentities.storage.DiskImage) Image(com.woorea.openstack.glance.model.v2.Image) RepoImage(org.ovirt.engine.core.common.businessentities.storage.RepoImage)

Example 22 with Image

use of com.google.cloud.vision.v1p3beta1.Image in project hortonmachine by TheHortonMachine.

the class GeopaparazziController method init.

@SuppressWarnings({ "serial" })
private void init() {
    _infoArea = new JTextPane();
    // _infoArea.setDocument(new SqlDocument());
    _infoArea.setContentType("text/html");
    _infoArea.setEditable(false);
    _infoScroll.setViewportView(_infoArea);
    // _infoScroll.setMinimumSize(new Dimension(10, 200));
    _chartHolder.setLayout(new BorderLayout());
    _loadFolderButton.setIcon(ImageCache.getInstance().getImage(ImageCache.REFRESH));
    _loadFolderButton.setText("");
    _loadFolderButton.setPreferredSize(preferredButtonSize);
    _loadFolderButton.addActionListener(e -> {
        final File geopaparazziFolder = new File(_projectsFolderTextfield.getText());
        if (!geopaparazziFolder.exists()) {
            GuiUtilities.showWarningMessage(this, null, "The projects folder doesn't exist.");
            return;
        }
        File[] projectFiles = GeopaparazziUtilities.getGeopaparazziFiles(geopaparazziFolder);
        try {
            projectInfos = readProjectInfos(projectFiles);
            layoutTree(projectInfos, false);
            _filterTextfield.setText("");
        } catch (Exception e1) {
            Logger.INSTANCE.insertError("", "error", e1);
        }
    });
    _projectsFolderBrowseButton.setPreferredSize(preferredButtonSize);
    _projectsFolderBrowseButton.addActionListener(e -> {
        File[] openFiles = guiBridge.showOpenDirectoryDialog("Open projects folder", PreferencesHandler.getLastFile());
        if (openFiles != null && openFiles.length > 0) {
            try {
                PreferencesHandler.setLastPath(openFiles[0].getAbsolutePath());
            } catch (Exception e1) {
                Logger.INSTANCE.insertError("", "ERROR", e1);
            }
        } else {
            return;
        }
        _projectsFolderTextfield.setText(openFiles[0].getAbsolutePath());
    });
    String lastSavedPath = prefsMap.get(GuiBridgeHandler.LAST_GP_PROJECTS_PATH);
    _projectsFolderTextfield.setText(lastSavedPath);
    _filterTextfield.addKeyListener(new KeyAdapter() {

        @Override
        public void keyReleased(KeyEvent e) {
            String filterText = _filterTextfield.getText().toLowerCase();
            final List<ProjectInfo> filtered = new ArrayList<ProjectInfo>();
            if (filterText == null) {
                filtered.addAll(projectInfos);
            } else {
                for (ProjectInfo projectInfo : projectInfos) {
                    if (projectInfo.fileName.toLowerCase().contains(filterText) || projectInfo.metadata.toLowerCase().contains(filterText)) {
                        filtered.add(projectInfo);
                    }
                }
            }
            layoutTree(filtered, false);
        }
    });
    addComponentListener(new ComponentListener() {

        public void componentShown(ComponentEvent e) {
        }

        public void componentResized(ComponentEvent e) {
        }

        public void componentMoved(ComponentEvent e) {
        }

        public void componentHidden(ComponentEvent e) {
            onClose();
        }
    });
    try {
        _databaseTreeView.setMinimumSize(new Dimension(300, 200));
        addJtreeDragNDrop();
        addJtreeContextMenu();
        _databaseTree.setRootVisible(false);
        _databaseTree.setCellRenderer(new DefaultTreeCellRenderer() {

            @Override
            public java.awt.Component getTreeCellRendererComponent(JTree tree, Object value, boolean selected, boolean expanded, boolean leaf, int row, boolean hasFocus) {
                super.getTreeCellRendererComponent(tree, value, selected, expanded, leaf, row, hasFocus);
                if (value instanceof ProjectInfo) {
                    setIcon(ImageCache.getInstance().getImage(ImageCache.DATABASE));
                } else if (value instanceof Image) {
                    setIcon(ImageCache.getInstance().getImage(ImageCache.DBIMAGE));
                } else if (value instanceof GpsLog) {
                    setIcon(ImageCache.getInstance().getImage(ImageCache.GEOM_LINE));
                } else if (value instanceof Note) {
                    setIcon(ImageCache.getInstance().getImage(ImageCache.NOTE));
                }
                return this;
            }
        });
        _databaseTree.addTreeSelectionListener(new TreeSelectionListener() {

            public void valueChanged(TreeSelectionEvent evt) {
                TreePath[] paths = evt.getPaths();
                currentSelectedProject = null;
                currentSelectedImage = null;
                currentSelectedNote = null;
                currentSelectedGpsLog = null;
                _chartHolder.removeAll();
                if (paths.length > 0) {
                    Object selectedItem = paths[0].getLastPathComponent();
                    if (selectedItem instanceof ProjectInfo) {
                        currentSelectedProject = (ProjectInfo) selectedItem;
                        selectProjectInfo(currentSelectedProject);
                        Logger.INSTANCE.insertDebug("", "Selected project: " + currentSelectedProject.fileName);
                    }
                    if (selectedItem instanceof Image) {
                        currentSelectedImage = (Image) selectedItem;
                        currentSelectedProject = getProjectForImage(currentSelectedImage);
                        selectImage(currentSelectedImage);
                        Logger.INSTANCE.insertDebug("", "Selected image: " + currentSelectedImage.getName() + " of project " + currentSelectedProject.fileName);
                    }
                    if (selectedItem instanceof GpsLog) {
                        currentSelectedGpsLog = (GpsLog) selectedItem;
                        currentSelectedProject = getProjectForGpsLog(currentSelectedGpsLog);
                        selectGpsLog(currentSelectedGpsLog);
                        Logger.INSTANCE.insertDebug("", "Selected gpslog: " + currentSelectedGpsLog.text + " of project " + currentSelectedProject.fileName);
                    }
                    if (selectedItem instanceof Note) {
                        currentSelectedNote = (Note) selectedItem;
                        currentSelectedProject = getProjectForNote(currentSelectedNote);
                        selectNote(currentSelectedNote);
                        Logger.INSTANCE.insertDebug("", "Selected note: " + currentSelectedNote.simpleText + " of project " + currentSelectedProject.fileName);
                    }
                }
            }
        });
        _databaseTree.setVisible(false);
    } catch (Exception e1) {
        Logger.INSTANCE.insertError("", "Error", e1);
    }
    layoutTree(null, false);
    Component wwjPanelComponent = null;
    try {
        wwjPanelComponent = NwwPanel.createNwwPanel(true);
    } catch (UnsatisfiedLinkError e1) {
    // ignore
    }
    if (wwjPanelComponent instanceof NwwPanel) {
        _nwwHolder.setLayout(new BorderLayout());
        _nwwHolder.add(wwjPanelComponent, BorderLayout.CENTER);
        wwjPanel = (NwwPanel) wwjPanelComponent;
        wwjPanel.addOsmLayer();
        geopapDataLayer = new RenderableLayer();
        wwjPanel.addLayer(geopapDataLayer);
    } else {
        _nwwHolderFrame.setVisible(false);
        _chartHolderFrame.setVisible(false);
        setPreferredSize(new Dimension(400, 600));
    }
}
Also used : RenderableLayer(gov.nasa.worldwind.layers.RenderableLayer) ComponentListener(java.awt.event.ComponentListener) KeyAdapter(java.awt.event.KeyAdapter) TreeSelectionListener(javax.swing.event.TreeSelectionListener) LineString(org.locationtech.jts.geom.LineString) Image(org.hortonmachine.gears.io.geopaparazzi.geopap4.Image) DefaultTreeCellRenderer(javax.swing.tree.DefaultTreeCellRenderer) KeyEvent(java.awt.event.KeyEvent) JTextPane(javax.swing.JTextPane) BorderLayout(java.awt.BorderLayout) EventListenerList(javax.swing.event.EventListenerList) List(java.util.List) ArrayList(java.util.ArrayList) Component(java.awt.Component) JComponent(javax.swing.JComponent) DaoGpsLog(org.hortonmachine.gears.io.geopaparazzi.geopap4.DaoGpsLog) GpsLog(org.hortonmachine.gears.io.geopaparazzi.geopap4.DaoGpsLog.GpsLog) Dimension(java.awt.Dimension) GpsPoint(org.hortonmachine.gears.io.geopaparazzi.geopap4.DaoGpsLog.GpsPoint) NwwPanel(org.hortonmachine.nww.gui.NwwPanel) JTree(javax.swing.JTree) Note(org.hortonmachine.gears.io.geopaparazzi.geopap4.Note) ComponentEvent(java.awt.event.ComponentEvent) TreeSelectionEvent(javax.swing.event.TreeSelectionEvent) File(java.io.File)

Example 23 with Image

use of com.google.cloud.vision.v1p3beta1.Image in project hortonmachine by TheHortonMachine.

the class OmsGeopaparazzi4Converter method media2FeatureCollection.

public static SimpleFeatureCollection media2FeatureCollection(IHMConnection connection, File mediaFolderFile, IHMProgressMonitor pm) throws Exception, IOException, FileNotFoundException {
    DefaultFeatureCollection newCollection = new DefaultFeatureCollection();
    try {
        GeometryFactory gf = GeometryUtilities.gf();
        /*
             * create the points shapefile
             */
        newCollection = new DefaultFeatureCollection();
        SimpleFeatureTypeBuilder b = new SimpleFeatureTypeBuilder();
        b.setName("geopaparazzimediapoints");
        b.setCRS(DefaultGeographicCRS.WGS84);
        b.add("the_geom", Point.class);
        String altimFN = ImageTableFields.COLUMN_ALTIM.getFieldName();
        String tsFN = ImageTableFields.COLUMN_TS.getFieldName();
        String azimFN = ImageTableFields.COLUMN_AZIM.getFieldName();
        String imageNameFN = ImageTableFields.COLUMN_TEXT.getFieldName();
        b.add(altimFN, String.class);
        b.add(tsFN, String.class);
        b.add(azimFN, Double.class);
        b.add(imageNameFN, String.class);
        SimpleFeatureType featureType = b.buildFeatureType();
        List<Image> imagesList = DaoImages.getImagesList(connection);
        pm.beginTask("Importing media...", imagesList.size());
        for (Image image : imagesList) {
            File newImageFile = new File(mediaFolderFile, image.getName());
            byte[] imageData = DaoImages.getImageData(connection, image.getImageDataId());
            try (OutputStream outStream = new FileOutputStream(newImageFile)) {
                outStream.write(imageData);
            }
            Point point = gf.createPoint(new Coordinate(image.getLon(), image.getLat()));
            long ts = image.getTs();
            String dateTimeString = ETimeUtilities.INSTANCE.TIME_FORMATTER_LOCAL.format(new Date(ts));
            String imageRelativePath = mediaFolderFile.getName() + "/" + image.getName();
            Object[] values = new Object[] { point, image.getAltim(), dateTimeString, image.getAzim(), imageRelativePath };
            SimpleFeatureBuilder builder = new SimpleFeatureBuilder(featureType);
            builder.addAll(values);
            SimpleFeature feature = builder.buildFeature(null);
            newCollection.add(feature);
            pm.worked(1);
        }
    } finally {
        pm.done();
    }
    return newCollection;
}
Also used : GeometryFactory(org.locationtech.jts.geom.GeometryFactory) SimpleFeatureTypeBuilder(org.geotools.feature.simple.SimpleFeatureTypeBuilder) OutputStream(java.io.OutputStream) FileOutputStream(java.io.FileOutputStream) MultiLineString(org.locationtech.jts.geom.MultiLineString) LineString(org.locationtech.jts.geom.LineString) Point(org.locationtech.jts.geom.Point) GpsPoint(org.hortonmachine.gears.io.geopaparazzi.geopap4.DaoGpsLog.GpsPoint) BufferedImage(java.awt.image.BufferedImage) Image(org.hortonmachine.gears.io.geopaparazzi.geopap4.Image) Date(java.util.Date) SimpleFeature(org.opengis.feature.simple.SimpleFeature) SimpleFeatureType(org.opengis.feature.simple.SimpleFeatureType) Coordinate(org.locationtech.jts.geom.Coordinate) FileOutputStream(java.io.FileOutputStream) JSONObject(org.json.JSONObject) File(java.io.File) DefaultFeatureCollection(org.geotools.feature.DefaultFeatureCollection) SimpleFeatureBuilder(org.geotools.feature.simple.SimpleFeatureBuilder)

Example 24 with Image

use of com.google.cloud.vision.v1p3beta1.Image in project hortonmachine by TheHortonMachine.

the class OmsGeopaparazzi4Converter method media2IdBasedFeatureCollection.

public static SimpleFeatureCollection media2IdBasedFeatureCollection(IHMConnection connection, IHMProgressMonitor pm) throws Exception, IOException, FileNotFoundException {
    try {
        GeometryFactory gf = GeometryUtilities.gf();
        /*
             * create the points fc
             */
        DefaultFeatureCollection newCollection = new DefaultFeatureCollection();
        SimpleFeatureType featureType = GeopaparazziUtilities.getMediaFeaturetype();
        List<Image> imagesList = DaoImages.getImagesList(connection);
        pm.beginTask("Importing media...", imagesList.size());
        for (Image image : imagesList) {
            Point point = gf.createPoint(new Coordinate(image.getLon(), image.getLat()));
            long ts = image.getTs();
            String dateTimeString = ETimeUtilities.INSTANCE.TIME_FORMATTER_LOCAL.format(new Date(ts));
            Object[] values = new Object[] { point, image.getAltim(), dateTimeString, image.getAzim(), image.getImageDataId() };
            SimpleFeatureBuilder builder = new SimpleFeatureBuilder(featureType);
            builder.addAll(values);
            SimpleFeature feature = builder.buildFeature(null);
            newCollection.add(feature);
            pm.worked(1);
        }
        return newCollection;
    } finally {
        pm.done();
    }
}
Also used : GeometryFactory(org.locationtech.jts.geom.GeometryFactory) Point(org.locationtech.jts.geom.Point) GpsPoint(org.hortonmachine.gears.io.geopaparazzi.geopap4.DaoGpsLog.GpsPoint) MultiLineString(org.locationtech.jts.geom.MultiLineString) LineString(org.locationtech.jts.geom.LineString) BufferedImage(java.awt.image.BufferedImage) Image(org.hortonmachine.gears.io.geopaparazzi.geopap4.Image) Date(java.util.Date) SimpleFeature(org.opengis.feature.simple.SimpleFeature) SimpleFeatureType(org.opengis.feature.simple.SimpleFeatureType) Coordinate(org.locationtech.jts.geom.Coordinate) JSONObject(org.json.JSONObject) DefaultFeatureCollection(org.geotools.feature.DefaultFeatureCollection) SimpleFeatureBuilder(org.geotools.feature.simple.SimpleFeatureBuilder)

Example 25 with Image

use of com.google.cloud.vision.v1p3beta1.Image in project openj9 by eclipse-openj9.

the class XMLIndexReader method setJ9DumpData.

public void setJ9DumpData(long environ, String osType, String osSubType, String cpuType, int cpuCount, long bytesMem, int pointerSize, Image[] imageRef, ImageAddressSpace[] addressSpaceRef, ImageProcess[] processRef) {
    Builder builder = null;
    if (_stream == null) {
        // extract directly from the file
        builder = new Builder(_coreFile, _reader, environ, _fileResolvingAgent);
    } else {
        // extract using the data stream
        builder = new Builder(_coreFile, _stream, environ, _fileResolvingAgent);
    }
    _coreFile.extract(builder);
    // Jazz 4961 : chamlain : NumberFormatException opening corrupt dump
    if (cpuType == null)
        cpuType = builder.getCPUType();
    String cpuSubType = builder.getCPUSubType();
    if (osType == null)
        osType = builder.getOSType();
    long creationTime = builder.getCreationTime();
    _coreImage = new Image(osType, osSubType, cpuType, cpuSubType, cpuCount, bytesMem, creationTime);
    ImageAddressSpace addressSpace = (ImageAddressSpace) builder.getAddressSpaces().next();
    ImageProcess process = (ImageProcess) addressSpace.getCurrentProcess();
    // If not sure, use the first address space/process pair found
    for (Iterator it = builder.getAddressSpaces(); it.hasNext(); ) {
        ImageAddressSpace addressSpace1 = (ImageAddressSpace) it.next();
        final boolean vb = false;
        if (vb)
            System.out.println("address space " + addressSpace1);
        _coreImage.addAddressSpace(addressSpace1);
        for (Iterator it2 = addressSpace1.getProcesses(); it2.hasNext(); ) {
            ImageProcess process1 = (ImageProcess) it2.next();
            if (vb)
                try {
                    System.out.println("process " + process1.getID());
                } catch (DataUnavailable e) {
                } catch (CorruptDataException e) {
                }
            if (process == null || isProcessForEnvironment(environ, addressSpace1, process1)) {
                addressSpace = addressSpace1;
                process = process1;
                if (vb)
                    System.out.println("default process for Runtime");
            }
        }
    }
    if (null != process) {
        // z/OS can have 64-bit or 31-bit processes, Java only reports 64-bit or 32-bit.
        if (process.getPointerSize() != pointerSize && !(process.getPointerSize() == 31 && pointerSize == 32)) {
            System.out.println("XML and core file pointer sizes differ " + process.getPointerSize() + "!=" + pointerSize);
        }
    } else {
        throw new IllegalStateException("No process found in the dump.");
    }
    imageRef[0] = _coreImage;
    addressSpaceRef[0] = addressSpace;
    processRef[0] = process;
}
Also used : ImageAddressSpace(com.ibm.dtfj.image.j9.ImageAddressSpace) ImageProcess(com.ibm.dtfj.image.j9.ImageProcess) Builder(com.ibm.dtfj.image.j9.Builder) Iterator(java.util.Iterator) DataUnavailable(com.ibm.dtfj.image.DataUnavailable) CorruptDataException(com.ibm.dtfj.image.CorruptDataException) Image(com.ibm.dtfj.image.j9.Image)

Aggregations

AnnotateImageRequest (com.google.cloud.vision.v1.AnnotateImageRequest)75 Image (com.google.cloud.vision.v1.Image)75 Feature (com.google.cloud.vision.v1.Feature)73 BatchAnnotateImagesResponse (com.google.cloud.vision.v1.BatchAnnotateImagesResponse)72 ImageAnnotatorClient (com.google.cloud.vision.v1.ImageAnnotatorClient)69 ArrayList (java.util.ArrayList)69 AnnotateImageResponse (com.google.cloud.vision.v1.AnnotateImageResponse)66 ByteString (com.google.protobuf.ByteString)52 ImageSource (com.google.cloud.vision.v1.ImageSource)41 FileInputStream (java.io.FileInputStream)32 EntityAnnotation (com.google.cloud.vision.v1.EntityAnnotation)28 WebImage (com.google.cloud.vision.v1.WebDetection.WebImage)26 IOException (java.io.IOException)20 ImageContext (com.google.cloud.vision.v1.ImageContext)14 SafeSearchAnnotation (com.google.cloud.vision.v1.SafeSearchAnnotation)11 WebDetection (com.google.cloud.vision.v1.WebDetection)11 LocationInfo (com.google.cloud.vision.v1.LocationInfo)10 Arrays (java.util.Arrays)10 Image (com.google.cloud.compute.v1.Image)9 ImagesClient (com.google.cloud.compute.v1.ImagesClient)9