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

  • Home
  • SEARCH
  • 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 8242377
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T21:08:51+00:00 2026-06-07T21:08:51+00:00

I always get this error when I run my program… i’m not sure about

  • 0

I always get this error when I run my program…

enter image description here

i’m not sure about what’s wrong with my program, FYI, actually my program consist of many image processing algorithm’s such as

  • viola-jones, haarcascade for hand detection
  • camshift + kalman filter for hand tracking
  • convex hull and convexity defects for counting finger
  • and other preprocessing ….

I have no idea whether these process triggering the error or not…

but when I remove convexhull / convexity defects, the errors gone…
any solution?

Edited : (added)

this is the code snippet

 private void ExtractContourAndHull()
        {
            using (MemStorage storage = new MemStorage())
            {
                
                Contour<Point> contours = backproject.FindContours(Emgu.CV.CvEnum.CHAIN_APPROX_METHOD.CV_CHAIN_APPROX_SIMPLE, Emgu.CV.CvEnum.RETR_TYPE.CV_RETR_LIST, storage);
                Contour<Point> biggestContour = null;

                Double Result1 = 0;
                Double Result2 = 0;
                while (contours != null)
                {
                    Result1 = contours.Area;
                    if (Result1 > Result2)
                    {
                        Result2 = Result1;
                        biggestContour = contours;
                    }
                    contours = contours.HNext;
                }

                if (biggestContour != null)
                {
                    //image.Draw(biggestContour, new Bgr(Color.DarkViolet), 2);
                    Contour<Point> currentContour = biggestContour.ApproxPoly(biggestContour.Perimeter * 0.005, storage);
                    image.Draw(currentContour, new Bgr(Color.LimeGreen), 2);
                    biggestContour = currentContour;
                 

                    hull = biggestContour.GetConvexHull(ORIENTATION.CV_CLOCKWISE);
                    box = biggestContour.GetMinAreaRect();
                    PointF[] points = box.GetVertices();
                    //handRect = box.MinAreaRect();
                    //image.Draw(handRect, new Bgr(200, 0, 0), 1);

                    Point[] ps = new Point[points.Length];
                    for (int i = 0; i < points.Length; i++)
                        ps[i] = new Point((int)points[i].X, (int)points[i].Y);

                    image.DrawPolyline(hull.ToArray(), true, new Bgr(200, 125, 75), 2);
                    image.Draw(new CircleF(new PointF(box.center.X, box.center.Y), 3), new Bgr(200, 125, 75), 2);

                    //ellip.MCvBox2D= CvInvoke.cvFitEllipse2(biggestContour.Ptr);
                    //image.Draw(new Ellipse(ellip.MCvBox2D), new Bgr(Color.LavenderBlush), 3);

                    //PointF center;
                    //float radius;
                    //CvInvoke.cvMinEnclosingCircle(biggestContour.Ptr, out  center, out  radius);
                    //image.Draw(new CircleF(center, radius), new Bgr(Color.Gold), 2);

                    //image.Draw(new CircleF(new PointF(ellip.MCvBox2D.center.X, ellip.MCvBox2D.center.Y), 3), new Bgr(100, 25, 55), 2);
                    //image.Draw(ellip, new Bgr(Color.DeepPink), 2);

                    //CvInvoke.cvEllipse(image, new Point((int)ellip.MCvBox2D.center.X, (int)ellip.MCvBox2D.center.Y), new System.Drawing.Size((int)ellip.MCvBox2D.size.Width, (int)ellip.MCvBox2D.size.Height), ellip.MCvBox2D.angle, 0, 360, new MCvScalar(120, 233, 88), 1, Emgu.CV.CvEnum.LINE_TYPE.EIGHT_CONNECTED, 0);
                    //image.Draw(new Ellipse(new PointF(box.center.X, box.center.Y), new SizeF(box.size.Height, box.size.Width), box.angle), new Bgr(0, 0, 0), 2);


                    filteredHull = new Seq<Point>(storage);
                    for (int i = 0; i < hull.Total; i++)
                    {
                        if (Math.Sqrt(Math.Pow(hull[i].X - hull[i + 1].X, 2) + Math.Pow(hull[i].Y - hull[i + 1].Y, 2)) > box.size.Width / 10)
                        {
                            filteredHull.Push(hull[i]);
                        }
                    }

                    defects = biggestContour.GetConvexityDefacts(storage, Emgu.CV.CvEnum.ORIENTATION.CV_CLOCKWISE);
                    
                    defectArray = defects.ToArray();
                }
            }
        }
        private void DrawAndComputeFingersNum()
        {
            using (MemStorage storage = new MemStorage())
            {
                int fingerNum = 0;
                
                

                #region hull drawing
                //for (int i = 0; i < filteredHull.Total; i++)
                //{
                //    PointF hullPoint = new PointF((float)filteredHull[i].X,
                //                                  (float)filteredHull[i].Y);
                //    CircleF hullCircle = new CircleF(hullPoint, 4);
                //    image.Draw(hullCircle, new Bgr(Color.Aquamarine), 2);
                //}
                #endregion


                #region defects drawing
                ***defects = new Seq<MCvConvexityDefect>(storage);***
                for (int i = 0; i < defects.Total; i++)
                {
                    PointF startPoint = new PointF((float)defectArray[i].StartPoint.X,
                                                    (float)defectArray[i].StartPoint.Y);

                    PointF depthPoint = new PointF((float)defectArray[i].DepthPoint.X,
                                                    (float)defectArray[i].DepthPoint.Y);

                    PointF endPoint = new PointF((float)defectArray[i].EndPoint.X,
                                                    (float)defectArray[i].EndPoint.Y);

                    LineSegment2D startDepthLine = new LineSegment2D(defectArray[i].StartPoint, defectArray[i].DepthPoint);

                    LineSegment2D depthEndLine = new LineSegment2D(defectArray[i].DepthPoint, defectArray[i].EndPoint);

                    CircleF startCircle = new CircleF(startPoint, 5f);

                    
                    CircleF depthCircle = new CircleF(depthPoint, 5f);
                  
                    CircleF endCircle = new CircleF(endPoint, 5f);
                    MCvFont angga = new MCvFont(Emgu.CV.CvEnum.FONT.CV_FONT_HERSHEY_SCRIPT_COMPLEX, 0.5, 0.5);
                   // image.Draw(defectArray[i].StartPoint.X.ToString() + " , " + defectArray[i].StartPoint.Y.ToString(), ref angga, new Point(defectArray[i].StartPoint.X, defectArray[i].StartPoint.Y), new Bgr(Color.Red));
                    image.Draw(defectArray[i].StartPoint.X.ToString() + " , " + defectArray[i].StartPoint.Y.ToString() + " , " + i.ToString(), ref angga, new Point(defectArray[i].StartPoint.X, defectArray[i].StartPoint.Y), new Bgr(Color.Red));

                    //Custom heuristic based on some experiment, double check it before use
                    if ((startCircle.Center.Y < box.center.Y || depthCircle.Center.Y < box.center.Y) && (startCircle.Center.Y < depthCircle.Center.Y) && (Math.Sqrt(Math.Pow(startCircle.Center.X - depthCircle.Center.X, 2) + Math.Pow(startCircle.Center.Y - depthCircle.Center.Y, 2)) > box.size.Height / 6.5))
                    {
                        fingerNum++;
                        //image.Draw(startDepthLine, new Bgr(Color.Blue), 2);
                        //image.Draw(depthEndLine, new Bgr(Color.Magenta), 2);
                    }


                    image.Draw(startCircle, new Bgr(Color.Red), 2);
                    image.Draw(depthCircle, new Bgr(Color.Yellow), 5);
                    //image.Draw(endCircle, new Bgr(Color.DarkBlue), 4);
                }
                #endregion

                MCvFont font = new MCvFont(Emgu.CV.CvEnum.FONT.CV_FONT_HERSHEY_DUPLEX, 5d, 5d);
                image.Draw(fingerNum.ToString(), ref font, new Point(50, 150), new Bgr(Color.White));
                hand.fingerChangedCompute = fingerNum;
            }

        }

       
        
        public MemStorage storage { get; set; } 

orgin
take a look at DrawandComputeFingersNUm() you’ll see a line

defects = new Seq<MCvConvexityDefect>(storage);

the problem will occur when I uncomment the line above..

anyone knows how to solve this problem?
any help would be appreciated..
thanks

  • 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-07T21:08:53+00:00Added an answer on June 7, 2026 at 9:08 pm

    as you know I’m the creator of the code you are using.

    One of my reader find sometimes an issue similar to yours, commented my post and suggest to remove the using Memstorage and put it globally then clear the storage inside DrawAndComputeFingersNum() function

    MemStorage storage = new MemStorage() //Global Declaration
    
    
    private void DrawAndComputeFingersNum()
        {
    
                int fingerNum = 0;
    
    
    
                #region hull drawing
                //for (int i = 0; i < filteredHull.Total; i++)
                //{
                //    PointF hullPoint = new PointF((float)filteredHull[i].X,
                //                                  (float)filteredHull[i].Y);
                //    CircleF hullCircle = new CircleF(hullPoint, 4);
                //    image.Draw(hullCircle, new Bgr(Color.Aquamarine), 2);
                //}
                #endregion
    
    
                #region defects drawing
                defects = new Seq<MCvConvexityDefect>(storage);
                for (int i = 0; i < defects.Total; i++)
                {
                    PointF startPoint = new PointF((float)defectArray[i].StartPoint.X,
                                                    (float)defectArray[i].StartPoint.Y);
    
                    PointF depthPoint = new PointF((float)defectArray[i].DepthPoint.X,
                                                    (float)defectArray[i].DepthPoint.Y);
    
                    PointF endPoint = new PointF((float)defectArray[i].EndPoint.X,
                                                    (float)defectArray[i].EndPoint.Y);
    
                    LineSegment2D startDepthLine = new LineSegment2D(defectArray[i].StartPoint, defectArray[i].DepthPoint);
    
                    LineSegment2D depthEndLine = new LineSegment2D(defectArray[i].DepthPoint, defectArray[i].EndPoint);
    
                    CircleF startCircle = new CircleF(startPoint, 5f);
    
    
                    CircleF depthCircle = new CircleF(depthPoint, 5f);
    
                    CircleF endCircle = new CircleF(endPoint, 5f);
                    MCvFont angga = new MCvFont(Emgu.CV.CvEnum.FONT.CV_FONT_HERSHEY_SCRIPT_COMPLEX, 0.5, 0.5);
                   // image.Draw(defectArray[i].StartPoint.X.ToString() + " , " + defectArray[i].StartPoint.Y.ToString(), ref angga, new Point(defectArray[i].StartPoint.X, defectArray[i].StartPoint.Y), new Bgr(Color.Red));
                    image.Draw(defectArray[i].StartPoint.X.ToString() + " , " + defectArray[i].StartPoint.Y.ToString() + " , " + i.ToString(), ref angga, new Point(defectArray[i].StartPoint.X, defectArray[i].StartPoint.Y), new Bgr(Color.Red));
    
                    //Custom heuristic based on some experiment, double check it before use
                    if ((startCircle.Center.Y < box.center.Y || depthCircle.Center.Y < box.center.Y) && (startCircle.Center.Y < depthCircle.Center.Y) && (Math.Sqrt(Math.Pow(startCircle.Center.X - depthCircle.Center.X, 2) + Math.Pow(startCircle.Center.Y - depthCircle.Center.Y, 2)) > box.size.Height / 6.5))
                    {
                        fingerNum++;
                        //image.Draw(startDepthLine, new Bgr(Color.Blue), 2);
                        //image.Draw(depthEndLine, new Bgr(Color.Magenta), 2);
                    }
    
    
                    image.Draw(startCircle, new Bgr(Color.Red), 2);
                    image.Draw(depthCircle, new Bgr(Color.Yellow), 5);
                    //image.Draw(endCircle, new Bgr(Color.DarkBlue), 4);
                }
                #endregion
    
                MCvFont font = new MCvFont(Emgu.CV.CvEnum.FONT.CV_FONT_HERSHEY_DUPLEX, 5d, 5d);
                image.Draw(fingerNum.ToString(), ref font, new Point(50, 150), new Bgr(Color.White));
                hand.fingerChangedCompute = fingerNum;
            storage.clear(); // clear storage allocation
    
        }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

run(/test.js) in mongo shell. i always get error run(/test.js) shell: started program /test.js sh2516|
I always get this error when i try to run my own programmed App.
I always get this error when trying to compile my file with Boost::GIL PNG
I'm trying to get this running: JAXB interface But I always get the error
If I open visual studio build and then build again I always get this
I've a field in the form,trying to get this value using jquery.It is always
This is a very simple question for compiler guys, but I always get confused
I have google'd it, and tried some examples, but I always get stuck. This
I always get confused when I am about to use a bit map to
I always get back Content Length Required 411, what am I doing wrong here?

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.