I use OpenCV and JME to make Augmented App .
The OpenCV part find the target , and save into boolean isTargetFound .
How to tell JME not Render model , When isTargetFound is fasle ?
Full Code: https://github.com/ar9013/Project_AR2
The ImageDetectionFilter class has a find findPose() to get the boolean isTargetFound
CameraAccessJMEActivity class to set the
final ARFilter Marker_fireworks to set the ImageDetectionFilter
try {
// Define The fireworks image to be 1.0 units tall.
Marker_fireworks = new ImageDetectionFilter(CameraAccessJMEActivity.this,
R.drawable.fireworks,
mCameraProjectionAdapter, 1.0);
} catch (IOException e) {
Log.e(TAG, "Failed to load drawable: " + "Marker_fireworks");
e.printStackTrace();
break;
}
mImageDetectionFilters = new ARFilter[] { Marker_mini, Marker_fireworks, Marker_pukeko };
((com.ar4android.cameraAccessJME.CameraAccessJME) app).setARFilter(mImageDetectionFilters[mImageDetectionFilterIndex]);
the CameraAccessJME class to Render Background and ForegroundScene ,the setARFilter use to set the boolean which ImageDetectionFilter from mTargetFound
public void setARFilter(ARFilter arFilter) {
filter = arFilter;
targetFound =filter.getFlagTargetFound();
if(targetFound){
pose = filter.getGLPose();
}
The boolean targetFound =filter.getFlagTargetFound(); use to determine to Render the ForegroundScene, the code is below
public void simpleInitApp() {
// Do not display statistics or frames per second
setDisplayStatView(false);
setDisplayFps(false);
// We use custom viewports - so the main viewport does not need to contain the rootNode
viewPort.detachScene(rootNode);
initVideoBackground(settings.getWidth(), settings.getHeight());
initBackgroundCamera();
if(targetFound){
initForegroundScene();
initForegroundCamera(fgCamFOVY);
}
}
When run , seen like the if statement can’t use in simpleInitApp().