I am trying to increase my frame rate using with Opencv for Android. While I get the process to run I do not notice any change in my frame rate. I am wondering if there is something wrong with my logic. Also after running for about 30 seconds it falls over with a buffer error.
What I have attempted to do was to use the main thread for the I/O display of the video and a second thread for object detection.
My main activity is the producer with "implements CvCameraViewListener2" this will put each frame on blocking queue IN and take them off Blocking Queue OUT .
I then have a Consumer runnable with the processing logic. This take them off the IN Blocking queue processes them and then puts them on the OUT queue.

public final class CameraActivity extends FragmentActivity implements CvCameraViewListener2 { Consumer consumer1 ; private BlockingQueue inFrames = new LinkedBlockingQueue(11);private BlockingQueue outFrames = new LinkedBlockingQueue(11); @Override public void onCameraViewStarted(final int width, final int height) { consumer1 = new Consumer(inFrames,outFrames); Thread thread1 = new Thread(consumer1); thread1.start(); } @Override public void onCameraViewStopped() { consumer1.stopRunning(); consumer2.stopRunning(); } @Override public Mat onCameraFrame(final CvCameraViewFrame inputFrame) { final Mat rgba = inputFrame.rgba(); // This is the producer of the blocking queue try { inFrames.put(inputFrame.rgba()); } catch (InterruptedException e) { } try { return outFrames.take(); } catch (InterruptedException e) { return rgba; }Consumer Class

public class Consumer implements Runnable {private final BlockingQueue queueIn;private final BlockingQueue queueOut;private boolean isRunning;public Consumer(BlockingQueue qIn, BlockingQueue qOut) { queueIn = qIn; queueOut = qOut; isRunning = true;}@Overridepublic void run() { try { while (isRunning) { consume(queueIn.take()); } } catch (InterruptedException ex) { }}void consume(Mat src) { Mat mIntermediateMat = new Mat(src.rows(), src.cols(), CvType.CV_8UC1); Mat dst = new Mat(src.size(), CvType.CV_8UC3); Mat mHsv = new Mat(src.size(), CvType.CV_8UC3); Mat mHsv2 = new Mat(src.size(), CvType.CV_8UC3); src.copyTo(dst); // Convert to HSV Imgproc.cvtColor(src, mHsv, Imgproc.COLOR_RGB2HSV, 3); // Remove all colors except the reds Core.inRange(mHsv, new Scalar(0, 86, 72), new Scalar(39, 255, 255), mHsv); Core.inRange(mHsv, new Scalar(150, 125, 100), new Scalar(180,255,255), mHsv2); Core.bitwise_or(mHsv, mHsv2, mHsv); /// Reduce the noise so we avoid false circle detection Imgproc.GaussianBlur(mHsv, mHsv, new Size(7, 7), 2); // Find Circles Imgproc.HoughCircles(mHsv, mIntermediateMat, Imgproc.CV_HOUGH_GRADIENT, 2.0, 100); // Find the largest circle int maxRadious = 0; Point pt = new Point(0,0); if (mIntermediateMat.cols() > 0) { for (int x = 0; x < mIntermediateMat.cols(); x++) { double vCircle[] = mIntermediateMat.get(0,x); if (vCircle == null) break; int radius = (int)Math.round(vCircle[2]); if (radius > maxRadious) { maxRadious = radius; pt = new Point(Math.round(vCircle[0]), Math.round(vCircle[1])); } } // Draw the larest circle in Red int iLineThickness = 5; Scalar red = new Scalar(255, 0, 0); // draw the found circle Core.circle(dst, pt, maxRadious, red, iLineThickness); try{ queueOut.put(dst); } catch (InterruptedException e) { } }}public void stopRunning() { this.isRunning = false;}}

Check Solution