Ask Your Question

SumeetB's profile - activity

2018-05-05 11:38:18 -0600 received badge  Famous Question (source)
2017-09-25 06:19:30 -0600 received badge  Notable Question (source)
2017-06-08 04:47:51 -0600 received badge  Popular Question (source)
2016-08-10 11:52:11 -0600 asked a question OpenCV4Android Lower Screen Resolution While Maintaining Fullscreen

I am making an OpenCV app on android that needs a lowered resolution of 640x480 to compensate for the heavy image processing I am doing. I do this in the main activity like so:

mOpenCvCameraView.setMaxFrameSize(640, 480);

Where mOpenCvCameraView is of type JavaCameraView. The problem with this is that it shrinks the dimensions of the actual frame so that the camera preview is not fullscreen. Is there a way to stretch the small frame to fit my phone screen's dimensions, or is there a better way of going about this? Thanks in advance!

2016-07-13 15:03:00 -0600 commented question OpenCV C++ Problem Connecting to IP Camera

That did it. Thanks :)

2016-07-13 14:46:52 -0600 asked a question OpenCV C++ Problem Connecting to IP Camera

I have an IP Camera (Android Camera) that my pc is successfully connected to. I want to grab frames from the camera and process them with opencv. However, my program is unable to display the frames from the camera. Here is the code I am using:

Mat frame;
stream1.open("http://{ipadress}:8080/videofeed?x.mjpeg");
while(true) {
  stream1 >> frame; 
  imshow("cam", frame);
}

This successfully compiles and on the IP Camera app on my phone the number of connections increases by 1, but imshow() just displays a gray screen and the cursor changes to a loading animation indefinitely. Any help with this problem would be greatly appreciated!

2016-07-11 10:00:30 -0600 asked a question OpenCV Android Set Camera Exposure?

I have made an OpenCV project for android that tracks certain objects that emit very bright, colored light. I want to set the exposure of my camera instead of it adjusting automatically, otherwise the color gets washed out and the camera only picks up white light from the objects. Is it possible to do this using CameraBridgeViewBase or JavaCameraView? If not, are there any alternatives such that the color information of the objects I am trying to detect are not lost?

Thanks in advance for your help!

2016-07-10 13:56:07 -0600 received badge  Supporter (source)
2016-07-08 13:36:30 -0600 asked a question Android Native Opencv Unresolved Inclusions After Import

I exported an opencv/android project in eclipse to a different workspace because the previous workspace path was preventing ndk-build from working. After importing the project and the opencv library to the new workspace, I get unresolved inclusion errors for all opencv imports only. Ex:

#include <jni.h>
#include <opencv2/imgproc/imgproc.hpp>
#include <vector>
#include "DropletsDetector.h"

using namespace std;
using namespace cv;

int GRAY_MIN = 220, GRAY_MAX = 254;

extern "C" {
JNIEXPORT void JNICALL     Java_com_urop_chemistrydropletsar_MainActivity_TrackDroplets(JNIEnv*, jobject, jlong addrRgba);

JNIEXPORT void JNICALL     Java_com_urop_chemistrydropletsar_MainActivity_TrackDroplets(JNIEnv*, jobject, jlong addrRgba)
{
    Mat& mCameraFrame = *(Mat*)addrRgba;
    Mat mGrayBinary;
    Mat mGrayFrame;
    DropletsDetector detector;

    cvtColor(mCameraFrame, mGrayFrame, CV_BGR2GRAY);
    inRange(mGrayFrame, GRAY_MIN, GRAY_MAX, mGrayBinary);
    detector.morphOps(mGrayBinary);
    detector.trackDropletsGrayScale(mCameraFrame, mGrayBinary);
}
}

jni.h and opencv2/imgproc/imgproc.hpp give unresolved inclusion errors and all code in "extern C" is underlined orange and says "syntax error"

I have done the following to try to resolve the errors:

Under C++ General paths and symbols, I have the following lines:

C:\Android\sdk\ndk-bundle\sources\cxx-stl\gnu-libstdc++\4.9\libs\armeabi-v7a\include

C:\Android\sdk\ndk-bundle\sources\cxx-stl\gnu-libstdc++\4.9\include

C:\Android\sdk\ndk-bundle\platforms\android-9\arch-arm\usr\include

C:\Android\OpenCV-android-sdk\sdk\native\jni\include

Also under project Properties->Android->Library I have OpenCV Library - 3.1.0 added.

I had fixed these errors when they were in the previous workspace, but exporting the project seems to have brought the errors back. Can anyone help me with this issue? Thanks in advance!

2016-07-01 14:23:53 -0600 commented answer OpenCV4Android Unsatisfied Linker Error Moments

My main need is to extract information from contours such as xy position and area. Is there also a way to get xy position without moments? Sorry I did not include that in my original post, I did not think it would be relevant.

Note: I hesitated moving away from moments because it easily gets this information in 3 lines of code. I submitted the issue to itseez github, so hopefully they can come up with a solution soon.

2016-07-01 13:24:32 -0600 commented answer OpenCV4Android Unsatisfied Linker Error Moments

Just checked the OpenCV Library manifest. I am using 3.1.0 and I have Moments imported.

2016-07-01 13:08:06 -0600 commented answer OpenCV4Android Unsatisfied Linker Error Moments

ok. I am using opencv 3.1.0, but I will try re-downloading the latest version from github.

2016-07-01 12:15:28 -0600 commented answer OpenCV4Android Unsatisfied Linker Error Moments

Tried it. Program does not reach the print statement. Problem is with the line "Moments moment = Imgproc.moments(contour);"

2016-06-30 13:27:27 -0600 asked a question OpenCV4Android Unsatisfied Linker Error Moments

I am getting the following error when I try to run my android application:

java.lang.UnsatisfiedLinkError: No implementation found for double[] org.opencv.imgproc.Imgproc.moments_1(long) (tried Java_org_opencv_imgproc_Imgproc_moments_11 and Java_org_opencv_imgproc_Imgproc_moments_11__J)

Here is the code where the problem is occurring:

Imgproc.findContours(temp, contours, hierarchy, Imgproc.RETR_EXTERNAL, Imgproc.CHAIN_APPROX_SIMPLE);

if(contours.size() > 0) {
    int numObjects = contours.size();

    if (numObjects < MAX_OBJECTS) {

        for (int i = 0; i < contours.size(); i++) {
            //moments causing unsatisfied linker error
            Moments moment = Imgproc.moments((Mat)contours.get(i));
            double area = moment.m00;
        }
    }
}

Can anyone help me with this problem? Thanks in advance!

2016-06-29 00:35:21 -0600 commented question OpenCV Convert C++ to Java

ok. Thanks!

2016-06-29 00:05:26 -0600 commented question OpenCV Convert C++ to Java

I am detecting objects who appear as halos in a binary matrix, so I thought RETR_EXTERNAL would be good to get the outer contours only. I want to traverse the hierarchy to get the area of each contour and filter out bad candidates based on a min_area threshold. I also use this later on in my program to get a rotated rect so I can draw ellipses around good candidates.

2016-06-28 17:47:29 -0600 received badge  Editor (source)
2016-06-28 11:28:24 -0600 asked a question OpenCV Convert C++ to Java

Hi all,

I have the following code written in c++:

vector<Vec4i> hierarchy;
vector<vector<Point>> contours;
findContours(temp, contours, hierarchy, RETR_EXTERNAL, CHAIN_APPROX_SIMPLE);
double refArea = 0;
if(hierarchy.size() > 0) {
     int numObjects = hierarchy.size();
    //do stuff
 for(int i = 0; i >= 0; i = hierarchy[i][0]) {
       Moments moment = moments((Mat)contours[i]);
       double area = moment.m00;
       //do more stuff
 }
}

I want to convert this to java for opencv android programming, but am unsure how. If anyone can help, that would be much appreciated!

2016-06-27 23:32:12 -0600 commented question OpenCV C++ Multithreading

@berak I was trying to implement something like this: http://www.pyimagesearch.com/2015/12/...

Except in c++ which I don't know how to do since I am new to opencv and multithreading. Also, if you would like to be helpful and show me how I can fix my mistakes, that would be much appreciated.

2016-06-27 11:22:51 -0600 asked a question OpenCV C++ Multithreading

I made a opencv c++ program that does a lot of image processing on frames from a video feed and as such decided to implement multithreading to speed things up. However, because I am new to opencv and multithreading, my implementation has caused my image processing functions to produce erroneous results. My guess is that the thread in which image processing occurs cannot keep up with the thread that reads in each frame. Here is my code:

void CaptureFrames() {
  VideoCapture capture(0);
  if (!capture.isOpened()) {
    cout << "cannot open camera" << endl;
  }

  while (true) {
    //CAMERAFRAME is a global Mat defined at the top of my program
    capture.read(CAMERAFRAME);
   }
  }

void ProcessFrames() {

  while (true) {



  Mat hsvFrame;
  Mat binMat;
  Mat grayFrame;
  Mat grayBinMat;

  if (!CAMERAFRAME.empty()) {
    //do image processing functions (these worked before implementing threads and are not causing errors)

    imshow("gray binary", grayBinMat);
    imshow("multithread test", CAMERAFRAME);
}



if (waitKey(1) >= 0) { break; }
 }
}

int main(int argc, char** argv[]) {
  thread t1(CaptureFrames);
  thread t2(ProcessFrames);

  while(true) {
    if(waitKey(1) >= 0) {break;}
  }

  return 0;
}

Any ideas on what I am doing wrong?

2016-02-07 17:39:39 -0600 asked a question OpenCV4Android Circular Object Tracking

I am new to OpenCV and trying to track a circular object using find contours on Android using 3.1.0. I am following the sample color blob detector to write the code, but the drawContours() function never draws anything when I run the application. Here is the onCameraFrame() function, which is doing all the processing. Can you tell me what I am doing wrong?

  public Mat onCameraFrame(CvCameraViewFrame inputFrame) {
    Mat rgba = inputFrame.rgba();
    List<MatOfPoint> contours = new ArrayList<MatOfPoint>();
    Mat hierarchy = new Mat();
    Mat grayMat = new Mat();
    Imgproc.cvtColor(rgba, grayMat, Imgproc.COLOR_RGBA2GRAY);
    Imgproc.findContours(grayMat, contours, hierarchy, Imgproc.RETR_EXTERNAL, Imgproc.CHAIN_APPROX_SIMPLE);
    double maxArea = 0;
    Iterator<MatOfPoint> each = contours.iterator();
    while(each.hasNext()){
        MatOfPoint wrapper = each.next();
        double area = Imgproc.contourArea(wrapper);
        if(area > maxArea){
            maxArea = area; 
        }

    }
    List<MatOfPoint> matchedContours = new ArrayList<MatOfPoint>();
    matchedContours.clear();
    while(each.hasNext()){
        MatOfPoint contour = each.next();
        if(Imgproc.contourArea(contour) > .1*maxArea){
            Core.multiply(contour, new Scalar(4,4), contour);
            matchedContours.add(contour);
        }
    }

    Imgproc.drawContours(rgba, matchedContours, -1, new Scalar(0,255,0));

    return rgba; 
}
2016-01-23 13:55:09 -0600 received badge  Enthusiast
2016-01-22 15:02:08 -0600 asked a question Android Round Object Tracking with OpenCV

Hi all. I have been following a tutorial on tracking circular/elliptical objects with OpenCV 3.1.0 on Android and I need some help with code optimization and improving the recognition accuracy. Currently, the code tries to find all circles in each frame and draw an outline around it. Since I am very new to OpenCV, I was hoping someone could help me with the following issues:

  • When the camera recognizes a circular object and draws an outline, the framerate drops to 1-2fps. Otherwise, the framerate is decent. How can I optimize my code to remedy this?

  • I want to track a very specific object which also happens to be an imperfect circle. By that, I mean there are indents around the circumference of the circle. Also, if possible, I want to be able to track the object from the side (the object is cylindrical), which means smooth transitions between drawing circles (top view) and drawing ellipses/rectangles with rounded corners (angled/side view).

  • I get a lot of false positives as well as recognition of other circular objects. I have considered thresholding the frames based on the specific color of the object I want to track (white), but I am unsure how to implement this. Any tutorials/other resources on doing this would be greatly appreciated!

public class MainActivity extends Activity implements CvCameraViewListener2 { private static final String TAG = "OCVSample::Activity";

private CameraBridgeViewBase mOpenCvCameraView;
private boolean              mIsJavaCamera = true;
private MenuItem             mItemSwitchCamera = null;

private BaseLoaderCallback mLoaderCallback = new BaseLoaderCallback(this) {
    @Override
    public void onManagerConnected(int status) {
        switch (status) {
            case LoaderCallbackInterface.SUCCESS:
            {
                Log.i(TAG, "OpenCV loaded successfully");
                mOpenCvCameraView.enableView();
                mOpenCvCameraView.setMaxFrameSize(640,480);
            } break;
            default:
            {
                super.onManagerConnected(status);
            } break;
        }
    }
};

public MainActivity() {
    Log.i(TAG, "Instantiated new " + this.getClass());
}

/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
    Log.i(TAG, "called onCreate");
    super.onCreate(savedInstanceState);
    getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);

    setContentView(R.layout.activity_main);

    mOpenCvCameraView = (CameraBridgeViewBase) findViewById(R.id.activity_main);

    mOpenCvCameraView.setVisibility(SurfaceView.VISIBLE);

    mOpenCvCameraView.setCvCameraViewListener(this);
}

@Override
public void onPause()
{
    super.onPause();
    if (mOpenCvCameraView != null)
        mOpenCvCameraView.disableView();
}

@Override
public void onResume()
{
    super.onResume();
    if (!OpenCVLoader.initDebug()) {
        Log.d(TAG, "Internal OpenCV library not found. Using OpenCV Manager for initialization");
        OpenCVLoader.initAsync(OpenCVLoader.OPENCV_VERSION_3_0_0, this, mLoaderCallback);
    } else {
        Log.d(TAG, "OpenCV library found inside package. Using it!");
        mLoaderCallback.onManagerConnected(LoaderCallbackInterface.SUCCESS);
    }
}

public void onDestroy() {
    super.onDestroy();
    if (mOpenCvCameraView != null)
        mOpenCvCameraView.disableView();
}

public void onCameraViewStarted(int width, int height) {
}

public void onCameraViewStopped() {
}

public Mat onCameraFrame(CvCameraViewFrame inputFrame) {
    Mat rgba = inputFrame.rgba();
    Core.flip(rgba, rgba, 1);
    Mat greyMat = new Mat(); 
    Imgproc.cvtColor(rgba, greyMat,Imgproc.COLOR_RGBA2GRAY , 0);
    Imgproc.GaussianBlur(greyMat, greyMat, new Size(9, 9), 2,2);
    double dp = 1.2d;
    double minDist = 100; 
    int minRadius = 0;
    int maxRadius = 0; 
    double param1 = 70, param2 = 72;
    Mat circles = new Mat();

    Imgproc.HoughCircles(greyMat, circles, Imgproc.HOUGH_GRADIENT, dp, minDist, param1, param2, minRadius, maxRadius);
    int numCircles = (circles.rows()==0) ? 0: circles.cols();
    for (int i = 0; i < numCircles; i++) {
        double[] circleCoordinates = circles.get(0, i);
        int x = (int) circleCoordinates[0], y ...
(more)
2016-01-05 21:41:52 -0600 asked a question OpenCV Android Color Blob Detection Build Error

I am trying to run the sample project color blob detection and I get the following error: "Errors occurred during the build. Errors running builder 'CDT Builder' on project 'OpenCV Sample - color-blob-detection'. java.lang.NullPointerException "

Full error report:


STATUS

pluginId org.eclipse.core.resources pluginVersion 3.10.1.v20150725-1910 code 2 severity 4 message Problems occurred when invoking code from plug-in: "org.eclipse.core.resources". fingerprint 76c9ec0d

Exception:java.lang.NullPointerException: null at org.eclipse.cdt.managedbuilder.internal.core.Tool.getOutputExtension(Tool.java:2356) at org.eclipse.cdt.managedbuilder.makegen.gnu.GnuMakefileGenerator.addRuleForSource(GnuMakefileGenerator.java:2355) at org.eclipse.cdt.managedbuilder.makegen.gnu.GnuMakefileGenerator.addFragmentMakefileEntriesForSource(GnuMakefileGenerator.java:2109) at org.eclipse.cdt.managedbuilder.makegen.gnu.GnuMakefileGenerator.addSources(GnuMakefileGenerator.java:2020) at org.eclipse.cdt.managedbuilder.makegen.gnu.GnuMakefileGenerator.populateFragmentMakefile(GnuMakefileGenerator.java:1018) at org.eclipse.cdt.managedbuilder.makegen.gnu.GnuMakefileGenerator.regenerateMakefiles(GnuMakefileGenerator.java:938) at org.eclipse.cdt.managedbuilder.internal.core.CommonBuilder.performMakefileGeneration(CommonBuilder.java:1006) at org.eclipse.cdt.managedbuilder.internal.core.CommonBuilder.performPrebuildGeneration(CommonBuilder.java:873) at org.eclipse.cdt.managedbuilder.internal.core.CommonBuilder.build(CommonBuilder.java:748) at org.eclipse.cdt.managedbuilder.internal.core.CommonBuilder.build(CommonBuilder.java:513) at org.eclipse.cdt.managedbuilder.internal.core.CommonBuilder.build(CommonBuilder.java:459) at org.eclipse.core.internal.events.BuildManager$2.run(BuildManager.java:734) at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:42) at org.eclipse.core.internal.events.BuildManager.basicBuild(BuildManager.java:205) at org.eclipse.core.internal.events.BuildManager.basicBuild(BuildManager.java:245) at org.eclipse.core.internal.events.BuildManager$1.run(BuildManager.java:300) at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:42) at org.eclipse.core.internal.events.BuildManager.basicBuild(BuildManager.java:303) at org.eclipse.core.internal.events.BuildManager.basicBuild(BuildManager.java:262) at org.eclipse.core.internal.events.BuildManager.build(BuildManager.java:402) at org.eclipse.core.internal.resources.Project$1.run(Project.java:556) at org.eclipse.core.internal.resources.Workspace.run(Workspace.java:2241) at org.eclipse.core.internal.resources.Project.internalBuild(Project.java:534) at org.eclipse.core.internal.resources.Project.build(Project.java:111) at HIDDEN.HIDDEN(HIDDEN:-1) at org.eclipse.core.internal.jobs.Worker.run(Worker.java:55)