Book Image

OpenCV for Secret Agents

By : Joseph Howse
Book Image

OpenCV for Secret Agents

By: Joseph Howse

Overview of this book

Table of Contents (15 chapters)
OpenCV for Secret Agents
Credits
About the Author
Acknowledgments
About the Reviewers
www.PacktPub.com
Preface
Index

Laying out a camera preview as the main view


Android, like many systems, enables the programmer to specify GUI layouts in XML files. Our Java code can load an entire view or pieces of it from these XML files.

Goldgesture has a simple layout that contains only a camera preview on which we will draw some additional graphics using OpenCV. The camera preview is represented by an OpenCV class called JavaCameraView. Let's edit res/layout/activity_camera.xml to fill the layout with JavaCameraView, using the front-facing camera, as follows:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
  xmlns:android="http://schemas.android.com/apk/res/android"
  xmlns:opencv="http://schemas.android.com/apk/res-auto"
  android:layout_width="match_parent"
  android:layout_height="match_parent" >

  <org.opencv.android.JavaCameraView
  android:layout_width="fill_parent"
  android:layout_height="fill_parent"
  android:id="@+id/camera_view"
  opencv:camera_id="front" />

</LinearLayout&gt...