use of com.adobe.cq.wcm.core.components.it.seljup.util.components.image.v2.Image in project aem-core-wcm-components by Adobe-Marketing-Cloud.
the class ImageIT method setupBeforeEach.
@BeforeEach
public void setupBeforeEach() throws ClientException {
imageTests = new ImageTests();
imageTests.setup(adminClient, contextPath, label, Commons.rtImage_v2, rootPage, defaultPageTemplate, clientlibs, new Image());
}
use of com.adobe.cq.wcm.core.components.it.seljup.util.components.image.v2.Image in project aem-core-wcm-components by Adobe-Marketing-Cloud.
the class ImageIT method setupBeforeEach.
@BeforeEach
public void setupBeforeEach() throws ClientException {
imageTests = new ImageTests();
imageTests.setup(adminClient, contextPath, label, Commons.rtImage_v1, rootPage, defaultPageTemplate, clientlibs, new Image());
}
use of com.adobe.cq.wcm.core.components.it.seljup.util.components.image.v2.Image in project openj9 by eclipse.
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;
}
use of com.adobe.cq.wcm.core.components.it.seljup.util.components.image.v2.Image in project java-docs-samples by GoogleCloudPlatform.
the class Detect method detectWebDetectionsGcs.
// [END vision_detect_web]
// [START vision_detect_web_uri]
/**
* Detects whether the remote image on Google Cloud Storage has features you would want to
* moderate.
*
* @param gcsPath The path to the remote on Google Cloud Storage file to detect web annotations.
* @param out A {@link PrintStream} to write the results to.
* @throws Exception on errors while closing the client.
* @throws IOException on Input/Output errors.
*/
public static void detectWebDetectionsGcs(String gcsPath, PrintStream out) throws Exception, IOException {
List<AnnotateImageRequest> requests = new ArrayList<>();
ImageSource imgSource = ImageSource.newBuilder().setGcsImageUri(gcsPath).build();
Image img = Image.newBuilder().setSource(imgSource).build();
Feature feat = Feature.newBuilder().setType(Type.WEB_DETECTION).build();
AnnotateImageRequest request = AnnotateImageRequest.newBuilder().addFeatures(feat).setImage(img).build();
requests.add(request);
try (ImageAnnotatorClient client = ImageAnnotatorClient.create()) {
BatchAnnotateImagesResponse response = client.batchAnnotateImages(requests);
List<AnnotateImageResponse> responses = response.getResponsesList();
for (AnnotateImageResponse res : responses) {
if (res.hasError()) {
out.printf("Error: %s\n", res.getError().getMessage());
return;
}
// Search the web for usages of the image. You could use these signals later
// for user input moderation or linking external references.
// For a full list of available annotations, see http://g.co/cloud/vision/docs
WebDetection annotation = res.getWebDetection();
out.println("Entity:Id:Score");
out.println("===============");
for (WebEntity entity : annotation.getWebEntitiesList()) {
out.println(entity.getDescription() + " : " + entity.getEntityId() + " : " + entity.getScore());
}
for (WebLabel label : annotation.getBestGuessLabelsList()) {
out.format("\nBest guess label: %s", label.getLabel());
}
out.println("\nPages with matching images: Score\n==");
for (WebPage page : annotation.getPagesWithMatchingImagesList()) {
out.println(page.getUrl() + " : " + page.getScore());
}
out.println("\nPages with partially matching images: Score\n==");
for (WebImage image : annotation.getPartialMatchingImagesList()) {
out.println(image.getUrl() + " : " + image.getScore());
}
out.println("\nPages with fully matching images: Score\n==");
for (WebImage image : annotation.getFullMatchingImagesList()) {
out.println(image.getUrl() + " : " + image.getScore());
}
out.println("\nPages with visually similar images: Score\n==");
for (WebImage image : annotation.getVisuallySimilarImagesList()) {
out.println(image.getUrl() + " : " + image.getScore());
}
}
}
}
use of com.adobe.cq.wcm.core.components.it.seljup.util.components.image.v2.Image in project java-docs-samples by GoogleCloudPlatform.
the class Detect method detectWebEntitiesGcs.
/**
* Find web entities given the remote image on Google Cloud Storage.
* @param gcsPath The path to the remote file on Google Cloud Storage to detect web entities.
* @param out A {@link PrintStream} to write the results to.
* @throws Exception on errors while closing the client.
* @throws IOException on Input/Output errors.
*/
public static void detectWebEntitiesGcs(String gcsPath, PrintStream out) throws Exception, IOException {
// Instantiates a client
try (ImageAnnotatorClient client = ImageAnnotatorClient.create()) {
// Set the image source to the given gs uri
ImageSource imageSource = ImageSource.newBuilder().setGcsImageUri(gcsPath).build();
// Build the image
Image image = Image.newBuilder().setSource(imageSource).build();
// Create the request with the image and the specified feature: web detection
AnnotateImageRequest request = AnnotateImageRequest.newBuilder().addFeatures(Feature.newBuilder().setType(Type.WEB_DETECTION)).setImage(image).build();
// Perform the request
BatchAnnotateImagesResponse response = client.batchAnnotateImages(Arrays.asList(request));
// Display the results
response.getResponsesList().stream().forEach(r -> r.getWebDetection().getWebEntitiesList().stream().forEach(entity -> {
System.out.format("Description: %s\n", entity.getDescription());
System.out.format("Score: %f\n", entity.getScore());
}));
}
}
Aggregations