2014-02-03 10:05:44 -0600 | asked a question | como alternar camera project color blob detection?? how to put cameras in the choice of color blob detection project activity ? this activity is already under codes : projet.colorblobtext package ; import android.os.Bundle ; import android.os.Environment ; import android.annotation.SuppressLint ; import android.app.Activity ; import java.text.SimpleDateFormat ; import java.util.Date ; import java.util.List ; import org.opencv.android.BaseLoaderCallback ; import org.opencv.android.CameraBridgeViewBase.CvCameraViewFrame ; import org.opencv.android.LoaderCallbackInterface ; import org.opencv.android.OpenCVLoader ; import org.opencv.core.Core ; import org.opencv.core.CvType ; import org.opencv.core.Mat ; import org.opencv.core.MatOfPoint ; import org.opencv.core.Rect ; import org.opencv.core.Scalar ; import org.opencv.core.Size ; import org.opencv.android.CameraBridgeViewBase ; import org.opencv.android.CameraBridgeViewBase.CvCameraViewListener2 ; import org.opencv.imgproc.Imgproc ; import android.util.Log ; import android.view.MotionEvent ; import android.view.View ; import android.view.View.OnClickListener ; import android.view.Window ; import android.view.WindowManager ; import android.view.View.OnTouchListener ; import android.widget.ImageButton ; public class extends Activity implements ColorBlobDetectionActivity OnTouchListener , { CvCameraViewListener2 private static final String TAG = " OCVSample :: Activity" ; mIsColorSelected private boolean = false ; Mat mRgba private ; Scalar private mBlobColorRgba ; Scalar private mBlobColorHsv ; private ColorBlobDetector mDetector ; Mat mSpectrum private ; private Size SPECTRUM_SIZE ; Scalar private CONTOUR_COLOR ; private CameraBridgeViewBase mOpenCvCameraView ; static int CAMERA_ID_BACK ; static int CAMERA_ID_FRONT ; private BaseLoaderCallback mLoaderCallback BaseLoaderCallback = new ( this) { @ Override public void onManagerConnected ( int status ) { switch ( status ) { LoaderCallbackInterface.SUCCESS case : { Log.i ( TAG , " OpenCV successfully loaded " ) ; mOpenCvCameraView.enableView (); mOpenCvCameraView.setOnTouchListener ( ColorBlobDetectionActivity.this ); Break } ; default: { super.onManagerConnected ( status ) ; Break } ; } } } ; public ColorBlobDetectionActivity ( ) { Log.i ( TAG , " Instantiated new" + this.getClass ( ) ) ; } / ** Called When the activity is first created . * / @ Override public void onCreate ( Bundle savedInstanceState ) { Log.i ( TAG , " onCreate called " ) ; super.onCreate ( savedInstanceState ) ; requestWindowFeature ( Window.FEATURE_NO_TITLE ); GetWindow ( ) setflags ( WindowManager.LayoutParams.FLAG_FULLSCREEN , WindowManager.LayoutParams.FLAG_FULLSCREEN ) . ; GetWindow ( ) addFlags ( WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON ) . ; setContentView ( R.layout.activity_color_blob_detection ) ; mOpenCvCameraView = ( CameraBridgeViewBase ) findViewById ( R.id.color_blob_detection_activity_surface_view ) ; mOpenCvCameraView.setCvCameraViewListener (this) ; } public void setCameraIndex ( int cameraIndex ) { / / I need help with choosing the cameras ! ! } @ Override public void onPause ( ) { super.onPause (); if ( mOpenCvCameraView ! = null ) mOpenCvCameraView.disableView (); } @ Override public void onResume ( ) { super.onResume (); OpenCVLoader.initAsync ( OpenCVLoader.OPENCV_VERSION_2_4_3 , this, mLoaderCallback ) ; } public void onDestroy ( ) { super.onDestroy (); if ( mOpenCvCameraView ! = null ) mOpenCvCameraView.disableView (); } public void onCameraViewStarted ( int width , int height ) { mRgba = new Mat ( height, width , CvType.CV_8UC4 ) ; mDetector ColorBlobDetector = new ( ) ; mSpectrum = new Mat ( ) ; mBlobColorRgba = new scalar ( 255); mBlobColorHsv = new scalar ( 255); SPECTRUM_SIZE = new Size ( 200, 64); CONTOUR_COLOR = new Scalar ( 255,0,0,255 ) ; } public void onCameraViewStopped ( ) { mRgba.release (); } public boolean OnTouch ( View v, MotionEvent event) { int cols = mRgba.cols ( ) ; int rows = mRgba.rows ( ) ; xOffset = int ( mOpenCvCameraView.getWidth () - cols ) / 2; yOffset = int ( mOpenCvCameraView.getHeight ( ) - rows ) / 2 ; int x = (int) event.getX () - xOffset ; int y = (int) event.getY () - yOffset ; Log.i ( TAG , "Touch image coordinates: ( " x + + "," + y + " )"); if ( ( x < 0 ) | | ( y < 0 ) | | ( x > cols ) | | ( y > rows) ) return false; TouchedRect Rect rect = new ( ) ; touchedRect.x = ( x > 4) ? 4 -x : 0 ; touchedRect.y = (y > 4) ? 4 - y 0; touchedRect.width = ( x +4 < cols ) ? x + 4 - touchedRect.x : cols - touchedRect.x ; touchedRect.height = ( y +4 < rows) ? y + 4 - touchedRect.y : rows - touchedRect.y ; Mat touchedRegionRgba = mRgba.submat ( touchedRect ) ; Mat touchedRegionHsv = new Mat ( ) ; Imgproc.cvtColor ... (more) |
2014-02-03 09:57:37 -0600 | asked a question | How to color blob detection switch the camera, take a picture and turn on/off the flash To make my application I am using the design color blob detection, where the camera is the type CameraBridgeViewBase, and I could find about this type was: and I need help because I can not also take pictures in this project!! I've tried to combine it with the 3 tutorial - Camera Control to power but unable to resolve, |