Rectangles to cover maximum area [duplicate] - python

This question already has answers here:
OpenCV Python: Draw minAreaRect ( RotatedRect not implemented)
(5 answers)
Find Rotated Rectangle in OpenCV Python
(1 answer)
Closed 2 years ago.
I been messing with Python and OpenCV on some images, and kind of got the result I want. Here is an example of the output image.
So the important part is opencv has draw red rectangles around the objects it has identified (I don't want to share what the original image was so yes those gray patches are all the remain after running a lot of functions on the image).
Now what I want to do is expand the rectangles (there are 2 here, but 3 or 4 are also possible) so they are as large as possible without touching. I just can't seem to come up with any kind of algorithm to do that. Any suggestions?

Related

Using different colours as mask and changing colour on target image [duplicate]

This question already has answers here:
Is it possible to change sprite colours in Pygame?
(1 answer)
Changing colour of a surface without overwriting transparency
(1 answer)
Trying to make sections of sprite change colour, but whole sprite changes instead
(1 answer)
Changing ememy's color to show that it is aking damage?
(1 answer)
Closed 6 months ago.
Image: Target Image
Image: Mask
I was wondering if there is a way using pygame to change the target image colours based on a mask that uses different colours for different areas.
What I thought of doing was to loop through the mask, check each pixel for its colour and if said colour is yellow for example, which is the area of the head, then to alter the saturation of the colour of the target image.
I'd like to know if there is a better way to do? Thank you

How to check whether two bounding boxes are overlapping in a frame ? [OpenCV] [duplicate]

This question already has answers here:
Intersection and difference of two rectangles
(3 answers)
Closed 2 years ago.
I am a noob and trying to learn OpenCV, I am working on a mini project which triggers certain functions if a person is detected in a specific area of the frame marked with a bounding box, can somebody guide how can I check whether a bounding box [ i.e detected object/person ] is overlapping with an already drawn bounding box[ i.e bounding box specified on a certain position of screen ] are overlapping?
In OpenCV python you'll have to implement this by hand. Check this for an implementation example.

Use Python and OpenCV to Play Two Camera Streams Picture-in-Picture Style [duplicate]

This question already has answers here:
overlay a smaller image on a larger image python OpenCv
(9 answers)
How to copy and paste of image as Picture-In-Picture in OpenCV [closed]
(1 answer)
Closed 3 years ago.
I'm trying to stream from two IP cameras and display them inside a single frame with one of them being the main camera (full screen) and the other as a smaller one on the lower right corner with both streaming real time. I already achieved this using Tkinter by placing 2 nested panels, however, I'm not happy with the framerate etc. probably due to GUI's own loop limiting the performance of my stream. That's why I'm trying to do it using only OpenCV but I wasn't able to find a solution so far. Really appreciate some help here.
Thanks!

Identifying Curved and Straight Objects in OpenCV [duplicate]

This question already has answers here:
how to remove straight lines or non-curvical lines in a canny image
(2 answers)
Closed 6 years ago.
I have the following image. My task is to examine the shape of worms (enclosed in rectangles) and classify them as dead/alive - the ones that are rod-like (straight) are dead and the curved ones are alive.
I have used adaptive thresholding on the source image, drawn the contours and bounding rectangles using OpenCV 3.1.0 in Python 2.7.1 . What would be the simplest and perhaps an efficient way to achieve the above aim.
(isConvex() certainly doesn't work :p)
One approach would be to compare the length of the contour (or worm) to the diagonal distance of the bounding box (upper left corner to bottom right corner distance). The straight ones will have a length closer to this distance than the curvy ones will.

How to make a heat map using python and openCV [duplicate]

This question already has answers here:
How to convert a grayscale image to heatmap image with Python OpenCV
(2 answers)
Closed 10 months ago.
I am trying to implement this:
YouTube link- https://www.youtube.com/watch?v=Qk4V_x6B7jY&t=5s
Blog link- http://www.businessinsider.in/These-Heat-Maps-Show-How-Retailers-Track-You-As-You-Shop/articleshow/29512380.cms
I want to use python and openCV but I am a beginner in openCV and hence, I have no idea How to implement this.
I have some basic idea. I have been able to track motion and draw a rectangle around the moving object and i am saving the co-ordinates of the rectangle in an external csv file. But, i am stuck on plotting heat map part. How to make it so that, over time when people are moving more and more in an area, the color changes from blue(normal movement ) to red (high movement) ? Please help..
So the basic idea for plotting a heat map is to visually get some feedback for the probability of a given particular event, You may write your own method which may take probability in range 0-1 and output a color in range (255, 0, 0) - (0, 0, 255). Or Opencv has provision of color-maps. You may be interested in using the COLORMAP_JET:
And Now you have to normalize the probability in range 0-255 instead of 0-1 and the you may use cv2.applyColorMap(input_prob, cv2.COLORMAP_JET) to get the desired output.

Categories