Extract one object from set of objects - c++

I want to extract one leaf from bunch of leaves to detect its features using OpenCV (C++). So first I tried to find edges of the image and extract one object. See my question here., but it seems that this way is not going to work. What I want to do is just extract one leaf from an image taken in real environment of the plant (See the following example image this is only an example. The image that is going to process is not known previously user has to take an image and to upload to the system)
As an example consider I want to cut off the leaf marked with red line.
Then I can proceed to identify features of that leaf. Can any one please suggest a step by step method to do this. I'm using OpenCV and C++ as the language.
Thank you in advance.

Related

How to build a "Bill Of Materials" automatically

I'm looking to auto-generate a Bill Of Materials (BOM) in draw.io by using object ID's. This is because my plans contain many of the same or similar components making it difficult to visually count. So, ultimately I'd like to auto-generate a parts list. Firstly is this possible in draw.io? Secondly what would be the best method of execution?
Currently I'm converting my diagram to PDF and then using the find function to count the number of instances of the part number.
A point in the right direction would be most welcome.

corrupted HEIC tile when converting to JPEG

I'm having trouble converting a .HEIC image to a jpeg. The .HEIC file an image taken with an iphone running the latest ios public beta. I'm using the library nokia provided to parse the file and extract the image tiles from the .HEIC file, convert them to jpeg and glue them together using ffmpeg/montage.
There is a bit too much code to paste it all into this question so i put all of it in this github repo. Its pretty self explanatory and should be runnable with just a few dependencies. They are explained in the repo's README. This has all been done on osx btw.
The .HEIC files contains a 8x6 grid of images(tiles) and if you put them together you get the complete image. Simply put whatever image i input the 7th tile is corrupted as shown below and i really don't understand why. I've filed an issue with nokia, but the repo seems pretty dead and i don't really expect an answer there.
There's a bug in the VPS/SPS/PPS parameter sets in the 7th tile. I have not tracked down if the issue lies in the actual file or in the HEIF parser, but there is a simple workaround in the meantime.
Refer to HevcImageFileReader::getItemDataWithDecoderParameters and observe how it prepends the parameter sets to the actual item data for each tile.
All you need to do is read the parameter sets for the first tile and reuse them for subsequent tiles instead of re-reading them. This will work around the corrupt parameters coming from the 7th tile. It appears safe to do this since this is a grid format and the requirement is that each tile be identical.

How to store array of groups in HDF5, one by one?

I'm having trouble finding the right documentation/examples for a task I've got. I want to store groups(?) which each contain:
one 8-bit RGB image
one 16-bit Grayscale image
one array of unsigned short values.
And I want to do this one by one. I.e. I'll perform some preprocessing to obtain the components of the group and then I want to store these before I move on to the next one. One thing to keep in mind is that I don't know how many such groups will end up being written. My idea would have been to create a new group directly under root every time, naming it by the current count, but I have a feeling there's a more elegant way to solve this. Any suggestions?
EDIT: I realize I only added the C++ tag and didn't mention it in the text. I'm stuck with C++ on this and can't use python.
EDIT2: This will later be used by the hdf5 layer in caffe
I think your initial idea is perfectly okay. Just name them foo1, ..., foo42, but also add an attribute containing the total number of groups to root (and update that each time you add a group).
Turns out I didn't need to bother much, since the C++ API for HDF5 doesn't support images.

Reduce a Caffe network model

I'd like to use Caffe to extract image features. However, it takes too long to process an image, so I'm looking for ways to optimize for speed.
One thing I noticed is that the network definition I'm using has four extra layers on top the one from which I'm reading a result (and there are no feedback signals, so they should be safe to delete).
I tried to delete them from the definition file but it had no effect at all. I guess I might need to remove the corresponding part of the file that contains pre-trained weights, too. That is, however, a binary file (a protobuffer) so editing it is not that easy.
Do you think that removing the four layers might have a profound effect of the net performance?
If so then how do I get familiar with the file contents so that I could edit it and how do I know which parts to remove?
first, I don't think removing the binary weights will have any effect.
Second, you can do it easily using the python interface: see this tutorial.
Last but not least, have you tried running caffe time to measure the performance of your net? this may help you identify the bottlenecks of your computations.
PS,
You might find this thread relevant as well.
Caffemodel stores data as key-value pair. Caffe only copies weight for those layers (in train.prototxt) having exactly same name as caffemodel. Hence I don't think removing binary weights will work. If you want to change network structure, just modify train.prototxt and deploy.txt.
If you insist to remove weights from binary file, follow this caffe example.
And to make sure you delete right part, this visualizing tool should help.
I would retrain on a smaller input size, change strides, etc. However if you want to reduce file size, I'd suggest quantizing the weights https://github.com/yuanyuanli85/CaffeModelCompression and then using something like lzma compression (xz for unix). We do this so we can deploy to mobile devices. 8 bit weights compress nicely.

Automatic Numberplate Recognition

As the title suggest, i want to build an ANPR application in windows. I am using Brazilian number plates. And i am using OpenCV for this.
So far i manged to extract the letters form the numberplate. Following images show some of the numbers i have extracted.
The problem i am facing is that how to recognize those letter. I tried to use Google tesseract. But it fails to recognize them sometimes. Then i tried to train an OCR data base using OpenCV i used about 10 images for each character. but it also did not work properly.
So i am stuck here. i need this for final year project.So can anybody help me?? i would really appreciate it.
Following site does it very nicely
https://www.anpronline.net/demo.html
Thank you..
you could train an ann or multi-class svm on the letter images, like here
Check out OpenALPR (http://www.openalpr.com). It already has the problem solved.
If you need to do it yourself, you really do need to train Tesseract. It will give you the best results. 10 images per character is not enough, you need dozens or hundreds. If you can find a font that is similar to your plate characters, a good approach is to print out a sheet of paper with all of the characters used multiple times. Then take 5-10 pictures of the page with your camera. These can then be your input for training Tesseract.