Как изменить цвет фона камеры при обнаружении кода с помощью Barcode Api с CameraSource Api? - PullRequest
0 голосов
/ 08 декабря 2018

Я разрабатываю приложение для Android, которое распознает штрих-код по камере, что я хочу делать, когда камера обнаруживает штрих-код. Мне нужно, чтобы фон камеры был серым. Я пытаюсь это ссылка , но все элементы в макете кадра исчезают, я надеюсь,чтобы найти решение
, что я хочу в изображении после обнаружения до обнаружения

мой код для действия камеры я сделал

  //set the event will done when detecte barcode by camera which must return 
//  barcode value to main activity

}

@Override
protected void onResume() {
    super.onResume();

    detector.setProcessor(new Detector.Processor<Barcode>() {
        @Override
        public void release() {
        }

        @Override
        public void receiveDetections(Detector.Detections<Barcode> 
 detections) {

            final SparseArray<Barcode> barcodes = 
 detections.getDetectedItems();

       //here the problem i want to add inthis condition something change 
// surfaceciew background or add filter to camera but code not work
            if (barcodes.size() != 0) {
                ring.start();
                Intent myintent=new Intent();
                myintent.putExtra("open", barcodes.valueAt(0).displayValue);
                setResult(CommonStatusCodes.SUCCESS,myintent);
                //  finish();



            }
        }
    });
}
}

и макет для активности камеры

    <?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
 xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:orientation="vertical"
android:layoutDirection="ltr"
android:id="@+id/myframecamera"
android:layout_height="match_parent"
tools:context=".Camera_activity">

<SurfaceView
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:layout_centerVertical="true"
    android:background="@drawable/camerashape"
    android:layout_alignParentLeft="true"
    android:id="@+id/camera_view"/>

<LinearLayout
    android:layout_width="match_parent"
    android:background="@color/gh"
    android:visibility="gone"
    android:orientation="vertical"
    android:id="@+id/colorchangelayout"
    android:layout_height="match_parent">

</LinearLayout>

<View
    android:layout_width="match_parent"
    android:layout_gravity="center"
    android:padding="30dp"

    android:layout_marginTop="25dp"
    android:layout_marginLeft="110dp"
    android:layout_marginRight="110dp"
    android:background="@color/blood"
    android:layout_height="3dp" />

<LinearLayout
    android:layout_width="match_parent"
    android:orientation="vertical"
    android:layoutDirection="ltr"
    android:layout_gravity="bottom"
    android:gravity="center"
    android:layout_height="wrap_content">

    <TextView
        android:layout_width="wrap_content"
        android:textColor="@color/white"
        android:text="place a barcode inside the viewfinder rectangle to 
scan it "
        android:id="@+id/resultmyscan"
        android:textSize="18sp"
        android:layout_height="wrap_content" />

    <Button
        android:layout_width="wrap_content"
        android:text="Cancel"
        android:id="@+id/backtomain"
        android:textColor="@color/black"
        android:background="@color/darkgray"
        android:layout_gravity="bottom|center"
        android:layout_margin="5dp"
        android:textSize="15sp"
        android:alpha=".5"
        android:layout_height="wrap_content" />

</LinearLayout>


</FrameLayout>

Я много чего пробую, но не могу, надеюсь найти решение или другой способ сделать это

Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...