Halcon - extract crate region - extract

I'm having huge difficulties to extract the region of the black crate from this image.
My situation is this:
the blue is a region that i have predefined as it is roughly where the crate has to be. I use it to reduce the domain of the image.
The yellow is the result i need: a filled region of the crate itself, as precise as possible.
I managed to extract the crate with the Saturation channel, but it includes too much from above the crate..
I tried R G B and H L S channels, combinig them between each other, but without success.. unfortunately I was not able to find a combination that extracts the crate reliably.
ATTENTION: in this picture there is the Blue crate behind.. but there can be any other crate. Also the black crate in front can have any height. I already sorted the situations where the front crate is blue or green, but for the black it is getting quite difficult...
Here is a Image with a low crate height...

I don’t think that it’s the right manner.
I think it’s better to avoid the conveyor belt and the window where you can see the other basket.
In a few words, you can use 2 domains: left and right.
In every domain, you can search for the basket part and then detect the line borders (left, top1, top2, right).
When you know these four lines (really only one top segment it’s necessary) you know where is the basket and you can reconstruct its region.

Related

Custom data lable and training-YoloV5 detection problem

I am doing some cat poop research and I tried to use YoloV5 to detect different types of poop in the litter box. I collected about 130 poop pictures (Just poop pictures with no background) and labeled them and use roboflow to get annotations, then I follow colab notebook to train data and get the best.pt file for detection. When I run detection using a ramdom litter box picture, the rectangle just marked the whole image or half of the image instead of marking the poops in that image.
Then I tried to labled 3 litter box images (Marked poops inside the litter box image) and do it all over again. But when I run detection using a litter box image. Nothing happened. I am so confused. Is it because poop shapes and color are so different to one and the other so it caused the detection didn't work.
Anyone could give me some clues on how to lable the images and train them?
Thank you
enter image description here
First i must say that your project is interesting and funny as well, no offence.
Your problem must be due to the number of training images. We cant expect the model to detect after training it with 130 images. Experts say we must use at least 1500 images for single class.
And some tips for labelling images in roboflow
Draw a box which includes all the parts of your interest. Dont leave any areas.
Try to avoid overlapping areas.

A basic query about Generative adversarial Models

Is it possible for the Generator to learn a distribution when noise is a specific input say n images instead of a random noise? For example, there are two categories of images with labels 0 and 1 say 0 for cats and 1 for dogs. Is it possible to learn the generator as we feed it a dog and it will generate a cat image against that dog image?
This query is somehow the same as deblurring images but what if no clear image is given against that blurred image but we are just given with random clear images.
Sure, it is possible. This is called style transfer and there have been a lot of works on that. In a way you learn a mapping function between the manifolds of dogs to the manifolds of cats. A famous work in that direction is the CycleGAN paper (https://arxiv.org/pdf/1703.10593.pdf), which uses a cycle consistent loss to map from one direction to the other and back. This makes the training more stable and the resulting images closer to the initial images.

Locate/Extract Patches from an Image

I have an image(e.g. 60x60) with multiple items inside it. Items are in the shape of square boxes, with say 4x4 dimensions, and are randomly placed within the image. The boxes(items) themselves are created with random patterns, some random pixels switched on and others switched off. So, it could be the same box repeated twice(or more in case of more than 2 items) in the image or could be entirely different.
I'm looking to create a deep learning model that could take in the original image(60x60) and output all the patches in the image.
This is all I have for now, but I can definitely share more details as the discussion starts. I'd be interested to weigh in different options that can help me achieve this objective. Thanks.
I would solve this using object detection. First I would train a network to detect those box like objects by cutting out patches of those objects. Then I would run a Faster R-CNN or something like this on it.
You might want to take a look at the stanford lecture on detection (slides here: http://cs231n.stanford.edu/slides/2017/cs231n_2017_lecture11.pdf).

AS3 - drawPath() & winding overlaps producing strange behavior

I'm trying to draw multiple shapes in the same Sprite.graphics scope, and can't seem to find any reasonable solution to my problem.
Please keep in minde that I've been using the drawPath() method for a performance problem : I could use multiple shapes with blendmodes, but I'd like to avoid that and keep performances cost to the minimum.
I've been experimenting with the winding parameter of the drawPath() method, but one thing that I cannot understand, is how the winding direction is defined by Flash, so here is a first question before actually coming to the real problem :
Are points coordinates taken in account ? Or is it the angle between the produces lines that define the direction ?
That being said, here is my actual problem :
I want to draw a shape that is a projection from a rectangle on a line - think of a window and the light that passes through it that goes hit the floor.
To achieve that, I must take into account that the lightsource position can vary and have that kind of results :
Here on that second picture you can already see the problem I'm facing.
To draw my shape, I've been separately "drawing" (understand : placing the numbers in my coordinates vector) the different parts of my figure : the actual rectangle I want to project, the light projected from its left side, the light projected from its bottom side, and the light projected from its right side.
I've been trying to carefully keep the winding direction the same in every section, beginning from the top-left corner, but it seems something is wrong in my reasoning, since every time the center part overlaps with any side part, the shape is emptied there, and every time the two sides parts overlaps, the same happens.
As I'm writing that here, some revelation suddenly strike me, and now I guess that maybe ALL my points in my coordinates vector must be sorted in the same winding direction for my shape to work ?... (and not only the small parts I'm separately drawing in my mind ^^)
If I'm right (please correct me if I'm not, or if I've understood anything wrong ?...), that means I must either :
sort my points to be placed in the correct winding direction (thing that might be complicated and could result in some strange drawed shape once provided to the drawing API ?...)
only draw the shape from the most external points, depending on the shape's actual shape (thing that might be more complicated that I currently expect).
Could anyone here confirm or infirm my last suppositions, and give me a clue on what could be going on here and how to solve it ?...
Thanks a lot :-)
You want to have one shape composed out of three projector lines? Okay, you have determined the positions of two lower points, and you have 4 points of your window. You then construct a list like so:
Two topmost points are always in the list, as you write that your light will always fall down out of the window. So, put 0 in command, window's upper left point coordinates into path, 1 into command (lineTo), window's upper right point into path.
Now, if both of your floor points have X less than lower right angle of the window, you add the window's point into the path!
Then you add rightmost floor point, then leftmost.
Then, if both of your floor points have X greater than lower LEFT corner of the window, you add it to the list.
You're done. And you will no longer need 3 projections, you calculate only the bottommost one (it'll give you both points on the floor), and make your list. Should do. Please comment.

How to find pixel co-ordinates of corners of a square pattern?

This may not be a programming related but possibly programmers would be in the best position to answer it.
For camera calibration I have a 8 x 8 square pattern printed on sheet of paper. I have to manually enter these co-ordinates into a text file. The software would then pick it up from there and compute the calibration parameters.
Is there a script or some software that I can run on these images and get the pixel co-ordinates of the 4 corners of each of the 64 squares?
You can do this with a traditional chessboard pattern (i.e. black and white squares with no gaps) using cvFindChessboardCorners(). You can read more about the function in the OpenCV API Reference and see some sample code in O'Reilly's OpenCV Book or elsewhere online. As an added bonus, OpenCV has built-in functions that calculate the intrinsic parameters of the camera and an array of extrinsic parameters for the multiple views of a planar calibration object.
I would:
apply threshold and get binarized image.
apply SobelX filter to image. You get an image with the vertical lines. This belong to the sides of the squares that are almost vertical. Keep this as image1.
apply SobelY filter to image. You get an image with the horizontal lines. This belong to the sides of the squares that are almost horizontal. Keep this as image2.
make (image1 xor image2). You get a black image with white pixels indicating the corner positions.
Hope it helps.
I'm sure there are many computer vision libraries with varying capabilities and licenses out there, but one that I can remember off the top of my head is ARToolKit, which should be able to recognize this pattern. And if that's not possible, it comes with a set of very good patterns that are tailored so that they can be recognized even if they're partially obscured.
I don't know ARToolKit (although i've heard a lot about it) but with OpenCV this processing is trivial.