Ask Your Question

Sqzr's profile - activity

2016-05-17 19:34:09 -0600 received badge  Editor (source)
2016-05-17 19:33:30 -0600 asked a question findContours Function causes crash across Windows & Ubuntu

When I use the OpenCV function findContours() my c++ application crashes. I've reproduced the error on both Windows 8.1 and Ubuntu. I've run into this crash before with the same function in my other OpenCV applications. Sometimes creating a new project and copying the exact same code resolves/avoids the error.

Below is the error message for both operating systems. Any advice what is going wrong?

Ubuntu Error:

OpenCV Error: Assertion failed (mtype == type0 || (CV_MAT_CN(mtype) == CV_MAT_CN(type0) && ((1 << type0) & fixedDepthMask) != 0)) in create, file /home/me/opencv/modules/core/src/matrix.cpp, line 2383 terminate called after throwing an instance of 'cv::Exception' what(): /home/me/opencv/modules/core/src/matrix.cpp:2383: error: (-215) mtype == type0 || (CV_MAT_CN(mtype) == CV_MAT_CN(type0) && ((1 << type0) & fixedDepthMask) != 0) in function create

Windows 8.1 error: image description

The line of code causing the error has been commented below. Note both Mat objects are not null and of the same size (640x480). I am using OpenCV 3.0

void trackMovingObject(Mat& thresholdImg, Mat& cameraFeed)
{
    std::vector<std::vector<Point>> contours;
    std::vector<Vec4d> hierarchy;

    // Crash occurs at below line
    // thresholdImg is created from cv::threshold()
    findContours(thresholdImg, contours, hierarchy, CV_RETR_EXTERNAL, CV_CHAIN_APPROX_SIMPLE);
2016-03-11 05:56:19 -0600 received badge  Famous Question (source)
2016-02-19 07:59:40 -0600 received badge  Notable Question (source)
2016-02-04 06:28:37 -0600 received badge  Popular Question (source)
2015-12-30 22:40:21 -0600 commented question Object Detection without Classifiers

@berak thanks for your comment, I mean if its possible to determine the depth/distance of the point from the camera. At the least figure out which object is relatively in front of another from the camera's perspective.

2015-12-30 18:13:37 -0600 asked a question Object Detection without Classifiers

I am attempting to crude application that identifies features or objects from a video stream, detects feature contours, attempts to group contours into separate objects and determines the depth of each contour point.

Being new to OpenCV I am unaware of the numerous techniques/approaches/algorithms I could use to achieve this. Given my order of operations below can you suggest OpenCV techniques/approaches/algorithms to use. I can then look further into these and learn along the way.

Order of Operations (I've elaborated on the techniques I know so far to use; please let me know of better and alternative techniques):

  • Read video stream
  • Identify contours: Apply gaussian blur to reduce noise, call findContours()
  • Classify objects: Inspect contours and identify which contours belong to which object. Any advice for this approach
  • For each contour point: determine the depth of this point. Any advice for this approach
2015-12-14 03:55:50 -0600 asked a question Terminology & Tutorial for Digitally Interpretting Environment

I am looking into coding a crude hobby C++ program that can Analyse a video stream and identify objects in that environment/frame (object depth & contours/shape). As this is not a trivial thing to do can you suggest any tutorials for this?

What is the term for this? Is there a term or area of expertise for this? 'Computer Vision' seems too broad of a term I believe. Maybe Computer Vision and Pattern Recognition (CVPR)? Object Detection? Environment Analysis?

If I know the term I can then search for tutorials. Also, if I know the algorithms involved I can search for these to get an idea how they work. Any advice of algorithms and approaches? Hough Circles, Colour identification, just simple contour identification (but how would I differentiate between objects), etc? I don't think Haar Cascade files would be appropriate/efficient solution because the program will encounter many different objects - its more about identifying obstacles and attempting a crude identification of an objects shape and depth.

2015-12-05 16:24:02 -0600 received badge  Supporter (source)
2015-12-05 16:21:51 -0600 commented question Identify Pepperoni Slice: Houghs Circles is Slow

@LBerger just saw your comment now. Heres a link to the original image. Going to go do some more tutorials and research algorithms. Thanks for your help

2015-12-05 05:04:20 -0600 commented question Identify Pepperoni Slice: Houghs Circles is Slow

@LBerger The objective is to count how many pepperoni slices are on each pizza - those pizzas with less than 7 will get a circle drawn around them. Any suggestions of the most appropriate algorithm that can achieve this?

2015-12-05 04:08:58 -0600 commented question Identify Pepperoni Slice: Houghs Circles is Slow

@LBerger thanks for your comment. Can you let me know what ROI stands for? I'm new to OpenCV, it doesn't mean return on investment? I'm not committed to hough circles so if there is another algorithm please let me know.

2015-12-05 00:51:46 -0600 asked a question Identify Pepperoni Slice: Houghs Circles is Slow

Hello

I am making a simple fun project that identifies how many pepperoni pieces/slices are on a pizza. The algorithm to count the no. of pepperoni slices is based off this example and is as follows:

  • For each video frame:
    • Convert to gray scale
    • Apply Gaussian Blur to reduce noise
    • Use Hough's Circle to identify all pepperoni slices and the pizza itself
    • If a circle sits inside another circle (pizza): then its a pepperoni slice

Example of the frame input: image description

The execution of the program is incredibly slow (as in 1 frame per second) and the algorithm is very hit and miss. Can you provide advice on why its slow, how I can achieve any speed increases and improve/alternative algorithms? Should I identify slices by their colour instead?

VideoCapture gCapture.open(VIDEO_SAMPLE_PATH);

while (true) {

    if (!gCapture.read(gCameraFeed))
    return -1;

    vector <Vec3f> circles;
    IdentifyCircles(gCameraFeed, circles);
    DrawPepperoni(gCameraFeed, circles);

    imshow(MAIN_WND_TITLE, gCameraFeed);

    // Exit on escape key down
    int c = waitKey(30);
    if ((char)c == 27)
        break;
}

int IdentifyCircles(const Mat& frame, vector<Vec3f>& circles)
{
    // Post: Use Hough Circles algorithm to identify all circles in frame

    Mat grayScaleFrame;
    circles.clear();

    cvtColor(frame, grayScaleFrame, CV_BGR2GRAY);
    GaussianBlur(grayScaleFrame, grayScaleFrame, Size(9, 9), 2, 2);
    HoughCircles(grayScaleFrame, circles, CV_HOUGH_GRADIENT, 1, grayScaleFrame.rows/8, 50, 50, 0, 0);
    putText(gCameraFeed, "Circles Identified: " + to_string(circles.size()), Point(20, 50), 1, 2, Scalar::all(200), 1, 8);

    return 1;
}