java图像增强_如何从Node.java文件访问增强图像的getIndex

在下面的代码中,如何将当前检测到的图像的索引分配给变量“value”?

public class AugmentedImageNode extends AnchorNode {

private static final String TAG = "AugmentedImageNode";

// The augmented image represented by this node.

private AugmentedImage image;

private static CompletableFuture ulCorner;

public AugmentedImageNode(Context context) {

if (value == 0) {

// Upon construction, start loading the models for the corners of the frame.

if (ulCorner == null) {

ulCorner =

ModelRenderable.builder()

.setSource(context, Uri.parse("models/tinker.sfb"))

//.setSource(context, Uri.parse("models/borderfence-small2.sfb"))

.build();

}

}

if (value == 1) {

// Upon construction, start loading the models for the corners of the frame.

if (ulCorner == null) {

ulCorner =

ModelRenderable.builder()

.setSource(context, Uri.parse("models/borderfence-small.sfb"))

//.setSource(context, Uri.parse("models/borderfence-small2.sfb"))

.build();

}

}

}

/**

* Called when the AugmentedImage is detected and should be rendered. A Sceneform node tree is

* created based on an Anchor created from the image. The corners are then positioned based on the

* extents of the image. There is no need to worry about world coordinates since everything is

* relative to the center of the image, which is the parent node of the corners.

*/

@SuppressWarnings({"AndroidApiChecker", "FutureReturnValueIgnored"})

public void setImage(AugmentedImage image) {

this.image = image;

// If any of the models are not loaded, then recurse when all are loaded.

if (!ulCorner.isDone())// || !urCorner.isDone() || !llCorner.isDone() || !lrCorner.isDone())

{

CompletableFuture.allOf(ulCorner)//, urCorner, llCorner, lrCorner)

.thenAccept((Void aVoid) -> setImage(image))

.exceptionally(

throwable -> {

Log.e(TAG, "Exception loading", throwable);

return null;

});

}

// Set the anchor based on the center of the image.

setAnchor(image.createAnchor(image.getCenterPose()));

// Make the 4 corner nodes.

Vector3 localPosition = new Vector3();

Node cornerNode;

// Upper left corner.

//localPosition.set(-0.5f * image.getExtentX(), 0.0f, -0.5f * image.getExtentZ());

localPosition.set(-0.0f * image.getExtentX(), 0.1f, +0.5f * image.getExtentZ());

cornerNode = new Node();

cornerNode.setParent(this);

cornerNode.setLocalPosition(localPosition);

cornerNode.setLocalRotation(Quaternion.axisAngle(new Vector3(-1f, 0, 0), 90f));

cornerNode.setRenderable(ulCorner.getNow(null));

}

private void setLocalRotation() {

}

public AugmentedImage getImage() {

return image;

}

}

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值