Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8178643
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T23:48:55+00:00 2026-06-06T23:48:55+00:00

Running into a problem with opencv 2.4.0 findContours function constantly crashing. Unfortunately, it’s been

  • 0

Running into a problem with opencv 2.4.0 findContours function constantly crashing. Unfortunately, it’s been very difficult for me to pinpoint the issue. Hoping someone has run into a similar problem.

I’m capturing the depth stream from a Kinect sensor using the Microsoft K4W SDK 1.5, copying that to an OpenCV Mat, then converting it to an 8UC1 image via cvtColor and threshold. I run a countNonZero just to be sure the image isn’t blank before passing it to findContours. But even the simplest findcountours implementation crashes.

Here’s my basic code:

rawdepth = Mat(Size(640,480),CV_8UC4);
thresh = Mat::zeros(640,480,CV_8UC1);

// storage for contours 
vector<vector<Point>> contours;

cvtColor(rawdepth,thresh,CV_RGB2GRAY);
threshold(thresh,thresh,0,255,THRESH_BINARY);

if(countNonZero(thresh) > 100 ) {
    // This crashes
    findContours(thresh,contours,RETR_EXTERNAL,CV_CHAIN_APPROX_NONE);           
} 

I did verify that the actual Mat being passed to findcontours is a single-channel image and that it is not blank (ie, there are some 500+ points). But I’m wondering if this is a heap or thread related problem since I’ve heard findcontours can actually modify the input Mat?

At this point I’m going to try and use OpenCV 2.4.1 which was just released, though I don’t see any fixed bugs that would point to fixing this problem.

Any ideas are much appreciated…

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-06T23:48:56+00:00Added an answer on June 6, 2026 at 11:48 pm

    The problem turned out to be a compiler flag which was limiting the program’s stack usage to 10MB (10,000,000 bytes). Unfortunately this wasn’t enough for the Kinect video I was capturing. After removing the compiler flag, the findContours will now compile and work properly!

    I’m using VC++ 2010 and the compiler flags were under Project Properties->Linker->System. The two fields were: “Stack Reserve Size” and “Stack Commit Size”

    After clearing them and recompiling, the project works beautifully!

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm running into this problem often: I'm creating a function that needs to perform
Been running into a problem ever since I started using rvm to manage my
I've been running into this problem a lot lately. I have an NSMutableArray called
Been running into this problem lately... When debugging an app in VS.Net 2005, breakpoints
I'm running into a problem setting up my development environment. I've been working on
I've been running into this problem with Flex for nearly a year, and each
I've been running into a problem where using objects from two datacontexts that are
I have been running into a problem with python's re module. This is the
I've been running into problem after problem trying to use the a third party
I'm running into a problem with MySQL's STR_TO_DATE function. For example, this code: SELECT

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.