当前位置: 首页>>代码示例>>Java>>正文


Java Label类代码示例

本文整理汇总了Java中com.amazonaws.services.rekognition.model.Label的典型用法代码示例。如果您正苦于以下问题:Java Label类的具体用法?Java Label怎么用?Java Label使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


Label类属于com.amazonaws.services.rekognition.model包,在下文中一共展示了Label类的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: processTask

import com.amazonaws.services.rekognition.model.Label; //导入依赖的package包/类
private void processTask(Message message) {
    String path = message.getBody();
    PathSplit pathComp = new PathSplit(path);
    String bucket = pathComp.bucket;
    String key = pathComp.key;
    Logger.Info("Processing %s %s", bucket, key);

    // Rekognition: Detect Labels from S3 object
    DetectLabelsRequest req = new DetectLabelsRequest()
        .withImage(new Image().withS3Object(new S3Object().withBucket(bucket).withName(key)))
        .withMinConfidence(minConfidence);
    DetectLabelsResult result;
    result = rek.detectLabels(req);
    List<Label> labels = result.getLabels();
    Logger.Debug("In %s, found: %s", key, labels);

    // Process downstream actions:
    for (LabelProcessor processor : processors) {
        processor.process(labels, path);
    }
}
 
开发者ID:jhy,项目名称:RekognitionS3Batch,代码行数:22,代码来源:Processor.java

示例2: handleRequest

import com.amazonaws.services.rekognition.model.Label; //导入依赖的package包/类
@Override
public Parameters handleRequest(Parameters parameters, Context context) {

    context.getLogger().log("Input Function [" + context.getFunctionName() + 
            "], Parameters [" + parameters + "]");

    // Create Rekognition client using the parameters available form the runtime context
    AmazonRekognition rekognitionClient = 
            AmazonRekognitionClientBuilder.defaultClient();

    // Create a Rekognition request
    DetectLabelsRequest request = new DetectLabelsRequest().withImage(new Image()
            .withS3Object(new S3Object().withName(parameters.getS3key())
                    .withBucket(parameters.getS3Bucket())));

    // Call the Rekognition Service
    DetectLabelsResult result = rekognitionClient.detectLabels(request);

    // Transfer labels and confidence scores over to Parameter POJO
    for (Label label : result.getLabels()) {
        parameters.getRekognitionLabels().put(label.getName(), label.getConfidence());
    }

    context.getLogger().log("Output Function [" + context.getFunctionName() +
            "], Parameters [" + parameters + "]");

    // Return the result (will be serialised to JSON)
    return parameters;
}
 
开发者ID:markwest1972,项目名称:smart-security-camera,代码行数:30,代码来源:RekognitionImageAssessmentHandler.java

示例3: process

import com.amazonaws.services.rekognition.model.Label; //导入依赖的package包/类
@Override
public void process(List<Label> labels, String path) {
    LabelInsertDoc doc = new LabelInsertDoc(labels, path);
    Logger.Debug("Json to push: \n%s", doc.asJson());

    byte[] jsonBytes = doc.asJsonBytes();
    UploadDocumentsRequest pushDoc = getUploadReq(jsonBytes);
    UploadDocumentsResult upRes = searchClient.uploadDocuments(pushDoc);

    Logger.Debug("Indexed %s, %s", path, upRes.getStatus());
}
 
开发者ID:jhy,项目名称:RekognitionS3Batch,代码行数:12,代码来源:CloudSearchIndexer.java

示例4: LabelContent

import com.amazonaws.services.rekognition.model.Label; //导入依赖的package包/类
public LabelContent(List<Label> rekLabels, String imgPath) {
    path = imgPath;
    labels = new ArrayList<>(rekLabels.size());
    confidence = new ArrayList<>(rekLabels.size());
    for (Label label : rekLabels) {
        labels.add(label.getName());
        confidence.add(label.getConfidence().intValue()); // decimal precision not required
    }
}
 
开发者ID:jhy,项目名称:RekognitionS3Batch,代码行数:10,代码来源:CloudSearchIndexer.java

示例5: process

import com.amazonaws.services.rekognition.model.Label; //导入依赖的package包/类
@Override
public void process(List<Label> labels, String imgPath) {

    String id = idHash.hashString(imgPath, charset).toString();
    Item item = new Item()
        .withPrimaryKey("id", id)
        .withString("path", imgPath)
        .withList("labels", labels.stream().map(DynamoWriter::labelToFields).collect(Collectors.toList()));

    table.putItem(item);
}
 
开发者ID:jhy,项目名称:RekognitionS3Batch,代码行数:12,代码来源:DynamoWriter.java

示例6: process

import com.amazonaws.services.rekognition.model.Label; //导入依赖的package包/类
@Override
public void process(List<Label> labels, String path) {
    Processor.PathSplit components = new Processor.PathSplit(path);
    String bucket = components.bucket;
    String key = components.key;

    // fetch the current set
    GetObjectTaggingResult tagging = s3.getObjectTagging(new GetObjectTaggingRequest(bucket, key));
    List<Tag> origTags = tagging.getTagSet();
    List<Tag> updateTags = new ArrayList<>();

    // copy the existing tags, but drop the ones matched by prefix (∴ leaves non-Rekognition label tags alone)
    for (Tag tag : origTags) {
        if (!tag.getKey().startsWith(tagPrefix))
            updateTags.add(tag);
    }
    
    // add the new ones
    for (Label label : labels) {
        if (updateTags.size() < maxTags)
            updateTags.add(new Tag(tagPrefix + label.getName(), label.getConfidence().toString()));
        else
            break;
    }

    // save it back
    s3.setObjectTagging(new SetObjectTaggingRequest(bucket, key, new ObjectTagging(updateTags)));
}
 
开发者ID:jhy,项目名称:RekognitionS3Batch,代码行数:29,代码来源:S3ObjectTagger.java

示例7: getLabels

import com.amazonaws.services.rekognition.model.Label; //导入依赖的package包/类
/**
 * returns label from file
 * 
 * @param filename
 * @return
 * @throws FileNotFoundException
 * @throws IOException
 * @throws URISyntaxException
 */
public List<Label> getLabels(String path) throws FileNotFoundException, IOException, URISyntaxException {
  if (path == null) {
    return getLabels();
  }
  
  InputStream inputStream = null;
  if (path.contains("://")) {      
    inputStream = new URL(path).openStream();     
  } else {
    inputStream = new FileInputStream(path);
  }   
  return getLabels(inputStream);
}
 
开发者ID:MyRobotLab,项目名称:myrobotlab,代码行数:23,代码来源:Rekognition.java

示例8: main

import com.amazonaws.services.rekognition.model.Label; //导入依赖的package包/类
public static void main(String[] args) throws Exception {

    Rekognition recog = (Rekognition) Runtime.start("recog", "Rekognition");

    /*
     * OpenCV opencv = (OpenCV) Runtime.start("opencv", "OpenCV");
     * opencv.capture();
     * 
     * sleep(1000); String photo = opencv.recordSingleFrame();
     * 
     * 
     * System.out.println("Detected labels for " + photo);
     */

    // set your credentials once - then comment out this line and remove the
    // sensitive info
    // the credentials will be saved to .myrobotlab/store
    // recog.setCredentials("XXXXXXXXXXXXXXXX",
    // "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX");
    recog.loadCredentials();
    List<Label> labels = null;
    // labels = recog.getLabels("opencv.input.48.jpg");
    labels = recog.getLabels("http://animals.sandiegozoo.org/sites/default/files/2016-08/hero_zebra_animals.jpg");
    for (Label label : labels) {

      System.out.println(label.getName() + ": " + label.getConfidence().toString());
    }

  }
 
开发者ID:MyRobotLab,项目名称:myrobotlab,代码行数:30,代码来源:Rekognition.java

示例9: LabelInsertDoc

import com.amazonaws.services.rekognition.model.Label; //导入依赖的package包/类
public LabelInsertDoc(List<Label> labels, String imgPath) {
    id = idHash.hashString(imgPath, charset).toString();
    fields = new LabelContent(labels, imgPath);
}
 
开发者ID:jhy,项目名称:RekognitionS3Batch,代码行数:5,代码来源:CloudSearchIndexer.java

示例10: labelToFields

import com.amazonaws.services.rekognition.model.Label; //导入依赖的package包/类
private static Map<String, Object> labelToFields(Label label) {
    HashMap<String, Object> map = new HashMap<>();
    map.put("name", label.getName());
    map.put("confidence", label.getConfidence());
    return map;
}
 
开发者ID:jhy,项目名称:RekognitionS3Batch,代码行数:7,代码来源:DynamoWriter.java

示例11: process

import com.amazonaws.services.rekognition.model.Label; //导入依赖的package包/类
public void process(List<Label>labels, String path); 
开发者ID:jhy,项目名称:RekognitionS3Batch,代码行数:2,代码来源:LabelProcessor.java


注:本文中的com.amazonaws.services.rekognition.model.Label类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。