如何使用CraftAR Camera将捕获的图像显示到下一个活动

时间:2019-01-28 01:45:13

标签: android camera image-recognition

我正在使用CraftAR进行图像识别,并且它已经拥有自己的相机(CraftAR相机)。

我已经搜索了可能的解决方案,但其中大多数都谈到了从设备调用相机意图。我尝试搜索与我的案例类似的相机api ,因为CraftAR相机不像其他人那样使用相机意图,但是我不明白如何在我的代码中使用/实现它。

如何将相机拍摄的图像显示到下一个活动?

RecognitionSingleShotActivity

    public class RecognitionSingleShotActivity extends CraftARActivity implements CraftARSearchResponseHandler, OnClickListener {

    private final static String TAG = "RecognitionSingleShotActivity";

    private View mScanningLayout;
    private View mTapToScanLayout;

    CraftAROnDeviceIR mOnDeviceIR;
    CraftARSDK mCraftARSDK;
    CraftARCamera mCamera;
    private boolean mIsActivityRunning;;

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
    }

    @Override
    public void onPostCreate() {

        setContentView(R.layout.activity_recognition_only);

        mCraftARSDK = CraftARSDK.Instance();
        mCraftARSDK.startCapture(this);

        mOnDeviceIR = CraftAROnDeviceIR.Instance(); 

        mCraftARSDK.setSearchController(mOnDeviceIR.getSearchController());

        mOnDeviceIR.setCraftARSearchResponseHandler(this);

        mCamera = mCraftARSDK.getCamera();

        mScanningLayout = findViewById(R.id.layout_scanning);
        mTapToScanLayout = findViewById(R.id.tap_to_scan);
        mTapToScanLayout.setClickable(true);
        mTapToScanLayout.setOnClickListener(this);  
    }

    @Override
    public void onCameraOpenFailed() {
        Toast.makeText(getApplicationContext(), "Camera error", Toast.LENGTH_SHORT).show();     
    }

    @Override
    public void onPreviewStarted(int width, int height) {

    }
    @Override
    public void onClick(View v) {
        if (v == mTapToScanLayout) {
            mTapToScanLayout.setVisibility(View.GONE);
            mScanningLayout.setVisibility(View.VISIBLE);
            mCraftARSDK.singleShotSearch();

        }
    }

    @Override
    public void searchResults(ArrayList<CraftARResult> result,
            long searchTimeMillis, int requestCode) {
        if(result.size()> 0){
            showResultDialog(result);
        }else{
            showNoObjectsDialog();
        }
    }
   ...
    private void showResultDialog(ArrayList<CraftARResult> results){
        if(!mIsActivityRunning){
            return;
        }

        String resultsText="";
        for(CraftARResult result:results){
            String itemName = result.getItem().getItemName();
            resultsText+= itemName + "\n";
        }
        resultsText = resultsText.substring(0,resultsText.length() - 1);    }
    ...

    }

我想使用ImageView在 RecognitionSingleShotActivityOutput 中显示它

0 个答案:

没有答案