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 9163581
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T14:28:46+00:00 2026-06-17T14:28:46+00:00

I need to find the min area rect ( cv2.minAreaRect() ) for a cloud

  • 0

I need to find the min area rect ( cv2.minAreaRect() ) for a cloud of white pixels.

I have multiple white object in my image and I want to draw a rect around them.

i found the solution in c++:

cv::cvtColor(img, gray, CV_BGR2GRAY);
std::vector<cv::Point> points;
cv::Mat_<uchar>::iterator it = gray.begin<uchar>();
cv::Mat_<uchar>::iterator end = gray.end<uchar>();
for (; it != end; ++it)
{
    if (*it) points.push_back(it.pos());
}
cv::RotatedRect box = cv::minAreaRect(cv::Mat(points));

this is my try in python:

gray = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY)
gray = cv2.GaussianBlur(gray, (5 ,5), 0)
retval, thresh = cv2.threshold(gray, 210, 255, cv2.THRESH_BINARY)
whitep = []
for y, row in enumerate(thresh):
    for x, px in enumerate(row):
        if px == 255:
            whitep.append((y, x))
box = cv2.minAreaRect(whitep)

but it doesn’t works:

box = cv2.minAreaRect(whitep)
TypeError: <unknown> is not a numpy array

how can I do?
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-17T14:28:47+00:00Added an answer on June 17, 2026 at 2:28 pm

    The python documentation for minAreaRect is misleading.

    Use:

    box = cv2.minAreaRect(numpy.array([whitep], dtype=numpy.int32))
    

    This passes an array of shape (1,N,2) to minAreaRect.

    You’ll need to specify the dtype if you are using a system where the default integer type is numpy.int64. It is safest to be explicit.

    See also: Checking contour area in opencv using python

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

Sidebar

Related Questions

I need to find min and max values in an array (not taking into
i need to find the records 10 min before system current datetime. select Id,TimeStamp
I have the need to find the next available number in a set: select
I have a situation where I need to find time spans between value changes.
I have a text I need to find in each proposal max word and
I have N keys. I need to find a data structure which i can
Given an array of size N I need to find the min number of
Column A is date Column B is criteria I want to find the MIN
I have a set of nested DIV 's and I need to find each
I need to find the max and min of a list and then add

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.