I'm beginning to work on a project with OpenCV (in python), and I'm trying to figure out the best way to tackle the problem I'm facing. I'm trying to get the area of an item in an image...but the surface area I'm looking for is on a 3D object.
So I found this while searching for calculating the area of a contour, but as you can see, this is only for a 2D object. For example, how could I find the area of the red question marks on the sphere in this image? Or the size of the rash on this baby's face (which is most certainly not 2-dimensional)? Is there a way to find the depth of the surface in the image, then use the high color gradient difference to find contours and calculate the difference based on the depths?
I found this deep learning paper (and associated PyTorch library), but was wondering if there was another way that I was missing...
Thanks to all for any ideas / replies.
My project is REM sleep detector, and the provided pictures show the contour of my eyelid. As my eye looks in directions, this contour moves in a distinct way. For lack of a better solution, my first attempt is to draw a grid of rois on my video stream, with that in place I want to use the countnonzero function or use blob detection on the rois. Depending on which rois in the grid change values, movement and direction is detected. (I am sure there is better way)
Problem: I can not specify one or several rois of my choice, the function always work only on the entire image. How do I retrieve values from each roi specifically? Rois are set up by means of multiple rectangle functions. Code is in python. Any help greatly appreciated.
Contour of eyelid:
I am trying to find the Australian Aboriginal flag in a collection of historic artwork.
Aboriginal Flag: https://i.imgur.com/sGsnLkv.png
Example Artworks: https://imgur.com/a/t6RisPx
I am new to OpenCV but have been programming for a long time.
I am confident I can code the solution but I can't seem to figure out what an easier solution would look like.
Should I;
Gray scale, find contours, find circles that exist inside rectangles where the area of the circle is a certain percentage area of the rectangle?
Find red, yellow, black shapes that have close proximity?
Gray scale, find circles that exist in rectangles. Then check if the circle is yellow in the original?
Anyone have any cool ideas on how to make this easy?
I plan on running this over 2.8 million images ahaha
My original reason is here -> https://news.ycombinator.com/item?id=24187794
Here's what I'm trying to mimic: https://www.youtube.com/watch?v=exXD6wJLJ6s
This guy is separating the video input into many square grids and analyzing each region to know what's going on in that specific region.
For me, it seemed like he was finding the dominant color for each grid. So I tried getting dominant colors on an image with KMean method and it worked well. (I'm trying to 'divide and conquer' the problem, by addressing the problem from the smallest part.)
However, I have no idea how to get dominant color for each grid region of an image. I think I should iterate through each grid square but how?
Furthermore, it seems almost impossible for me to do the above task on a video. Can the same algorithm (detecting dominant color in an image (region)) also apply to real-time detection of a video? Wouldn't it be too sluggish?
I'm really new to OpenCV and I'm basically just following whatever tutorials that seem to be related to my project.
To sum up: I got dominant color from the image following the below tutorial and now I want to do this for each grid of an image/video.
https://www.pyimagesearch.com/2014/05/26/opencv-python-k-means-color-clustering/
This is what I've done so far:
I drew the grid on MSPaint:
I am trying to extract the tiles ( Letters ) placed on a Scrabble Board. The goal is to identify / read all possible words present on the board.
An example image -
Ideally, I would like to find the four corners of the scrabble Board, and apply perspective transform, for further processing.
After Perspective transform -
The algorithm that I am using is as follows -
Apply Adaptive thresholding to the gray scale image of the Scrabble Board.
Dilate / Close the image, find the largest contour in the given image, then find the convex hull, and completely fill the area enclosed by the convex hull.
Find the boundary points ( contour ) of the resultant image, then apply Contour approximation to get the corner points, then apply perspective transform
Corner Points found -
This approach works with images like these. But, as you can see, many square boards have a base, which is curved at the top and the bottom. Sometimes, the base is a big circular board. And with these images my approach fails. Example images and outputs -
Board with Circular base:
Points found using above approach:
I can post more such problematic images, but this image should give you an idea about the problem that I am dealing with. My question is -
How do I find the rectangular board when a circular board is also present in the image?
Some points I would like to state -
I tried using hough lines to detect the lines in the image, find the largest vertical line(s), and then find their intersections to detect the corner points. Unfortunately, because of the tiles, all lines seem to be distorted / disconnected, and hence my attempts have failed.
I have also tried to apply contour approximation to all the contours found in the image ( I was assuming that the large rectangle, too, would be a contour ), but that approach failed as well.
I have implemented the solution in openCV-python. Since the approach is what matters here, and the question was becoming a tad too long, I didn't post the relevant code.
I am willing to share more such problematic images as well, if it is required.
Thank you!
EDIT1
#Silencer's answer has been mighty helpful to me for identifying letters in the image, but I want to accurately find the placement of the words in the image. Hence, I feel identifying the rows and columns is necessary, and I can do that only when a perspective transform is applied to the board.
I wrote an answer on MSER text detection:
Trying to Plot OpenCV's MSER regions using matplotlib
The code generate the following results on your images.
You can have a try.
I think #silencer has already given quite promising solution.
But to perform perspective transform as you have mentioned that you have already tried with hough lines to find the largest rectangle but it fails because for tiles present.
Given you have large image data set may be more than 1000 images, you can also give a shot to Deep learning based approach where you can train a model with images as input and corresponding rectangle boundary points coordinate as outputs.