Наложение кадрирования, чтобы отметить поле сканирования - PullRequest
0 голосов
/ 03 мая 2019

Я внедрил сканер штрих-кода в наше приложение Xamarin.Для реализации сканера я следовал этому руководству: https://www.c -sharpcorner.com / article / xamarin-android-qr-code-reader-by-mobile-camera /

Итак, яиметь SurfaceView, CameraSource и BarcodeDetector.Теперь я хочу обрезать предварительный просмотр камеры, чтобы сказать сканеру, где находится штрих-код, в котором мы должны сканировать, поскольку возможно, что источник, из которого мы можем иметь более одного штрих-кода.

Я думаю, что это будет работать сПростой Crop View (или что-то подобное), но я не знаю, как это реализовать.Все найденные решения не работают или я что-то упустил.

1 Ответ

0 голосов
/ 06 мая 2019

Хотите ли вы получить такой же GIF?

enter image description here

Если это так, вы можете достичь этого с ZXing.Net.Mobile https://github.com/Redth/ZXing.Net.Mobile

Вот мое демо https://github.com/851265601/Scanebarcode

Обновление: если вы все еще хотите использовать решение, например, взорванную ссылку

https://www.c -sharpcorner.com / статьи / Xamarin-андроида-ор-кода читателя по-мобильно-камера /

Я изменил макет, как показано ниже. Я usd FramLayout, SurfaceView был покрыт другим raylout, как LinearLayout или relativelayout

<FrameLayout 
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
>
<SurfaceView
            android:id="@+id/cameraView"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:layout_centerInParent="true" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
>
<RelativeLayout
    android:background="#953399ff"
    android:layout_width="fill_parent"
    android:layout_height="0dp"
    android:layout_weight="1" />
<LinearLayout
    android:layout_width="fill_parent"
    android:layout_height="330dp"
    android:orientation="horizontal">
    <RelativeLayout
        android:background="#953399ff"
        android:layout_width="0dp"
        android:layout_height="fill_parent"
        android:layout_weight="1" />
    <RelativeLayout
        android:id="@+id/rlscan"
        android:layout_width="220dp"
        android:layout_height="fill_parent">

        <ImageView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_alignParentLeft="true"
            android:layout_alignParentTop="true"
            android:src="@drawable/area_above_left" />
        <ImageView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_alignParentRight="true"
            android:layout_alignParentTop="true"
            android:src="@drawable/area_above_right" />
        <ImageView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_alignParentBottom="true"
            android:layout_alignParentLeft="true"
            android:src="@drawable/area_below_left" />
        <ImageView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_alignParentBottom="true"
            android:layout_alignParentRight="true"
            android:src="@drawable/area_below_right" />
    </RelativeLayout>
    <RelativeLayout
        android:background="#953399ff"
        android:layout_width="0dp"
        android:layout_height="fill_parent"
        android:layout_weight="1" />
</LinearLayout>
<RelativeLayout
    android:background="#953399ff"
    android:layout_width="fill_parent"
    android:layout_height="0dp"
    android:layout_weight="1">
    <TextView
        android:layout_centerInParent="true"
        android:gravity="center_horizontal"
        android:id="@+id/txtResult"
        android:layout_below="@+id/cameraView"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:text="Please focus Camera to QR Code"
        android:textSize="10sp"
        android:layout_marginTop="20dp" />
  </RelativeLayout>
  </LinearLayout>
</FrameLayout>
...