fernaper / cv2-tools Goto Github PK
View Code? Open in Web Editor NEWv2.4.0 - Library to help the drawing process with OpenCV. Thought to add labels to the images. Classification of images and much more.
License: MIT License
v2.4.0 - Library to help the drawing process with OpenCV. Thought to add labels to the images. Classification of images and much more.
License: MIT License
Bug
They just don't do what they should.
The algorithm that calculates all tags positions solves the problem if there is a perfect solution (is possible to find a solution without coliding tags with other tags or frames).
But if there is no option, right now it just ignore all the constraints and decide in order of priority.
Im thinking about soft constraints. With them we can choose the option with less coliding tags.
This could be a really amazing issue.
Now we are capable detect change of scenes, so if now we can track objects we will be capable to easyli create efficient methods to process video detection.
Make it possible to process half of a video in the first time, and reproduce the first half and process and save the second one
Traceback (most recent call last):
File "/var/www/facesync/script/edit_cron.py", line 245, in
edit_folder(folder, people_store, remove_videos=True)
File "/var/www/facesync/script/edit_cron.py", line 182, in edit_folder
edit_file(**video)
File "/var/www/facesync/script/edit_cron.py", line 196, in edit_file
save = generate_video_without_audio(complete_path, tmp_video, people_store)
File "/var/www/facesync/script/edit_cron.py", line 112, in generate_video_without_audio
frame = selector.draw(frame)
File "/usr/local/lib/python3.4/dist-packages/cv2_tools/Selection.py", line 230, in draw
specific_properties=self.specific_properties)
File "/usr/local/lib/python3.4/dist-packages/cv2_tools/Utils.py", line 549, in select_multiple_zones
position = best_position[i]
IndexError: list index out of range
This is a multiprocessing way to reproduce videos:
https://www.pyimagesearch.com/2017/02/06/faster-video-file-fps-with-cv2-videocapture-and-opencv/
Im thinking about being capable to decide properties for each rectangle instead of a property per object.
If a frame have so much zones selected with lots of tags, right now you cant see easily to whom each tag belongs.
Change priority positions
If not tags position are provided:
- First try to put the text on the Bottom Rigth corner
- If it doesn't fit, try to put the text Bottom Left corner
- If it doesn't fit, try to put the text Inside the rectangle
- If it doesn't fit, try to put the text On top of the rectangle
If something is going wrong its a good idea to print some warnings (in stderr).
This will be usefull for the users.
Traceback (most recent call last):
...
frame = selector.draw(frame)
File "/usr/local/lib/python3.6/dist-packages/cv2_tools/Selection.py", line 230, in draw
specific_properties=self.specific_properties)
File "/usr/local/lib/python3.6/dist-packages/cv2_tools/Utils.py", line 565, in select_multiple_zones
frame = select_zone(frame, zone, tags=tags, tag_position=position,
UnboundLocalError: local variable 'position' referenced before assignment
Traceback (most recent call last):
File "people_counter_ever.py", line 124, in
frame = selector.draw(frame)
File "/usr/local/lib/python3.6/dist-packages/cv2_tools/Selection.py", line 230, in draw
specific_properties=self.specific_properties)
File "/usr/local/lib/python3.6/dist-packages/cv2_tools/Utils.py", line 565, in select_multiple_zones
frame = select_zone(frame, zone, tags=tags, tag_position=position,
UnboundLocalError: local variable 'position' referenced before assignment
@Campos5 ideas
Add Readme.md and create Wiki with all the needed information
I don't know why, but if you change the default value of the parameter margin
, it will do weird things.
For now, until it is fixed, just don't change this value.
More or less the same as in the issue #34 but this time for Utils.py
We want co be capable to change the tag color, the alpha of the rectangle, and all that kind of features.
Also we will need to be capable to save and load this data
We want to be capable to install this package via pip
, this is why we need to create the setup with all the dependencies.
The sooner the better to be able to add versions.
The problem is that position now is an object of type Rectangle.
But we should be capable to use it as in previous versions,
I must found a better way to manage keystrokes, because right now it is so hard
I think that some times an example is better than an explanation.
So, It could be a good idea to create a basic example with each class, independent with the others.
Then we can create examples with more than one class, and finally a complete example.
The objective of this library is to have a fast development using OpenCV, therefore we can create an object to manage videos or streams in an easiest way than the basic OpenCV.
Possible workflows:
This library will be amazing if it is capable to manage YOLOv3 Automatically.
I don't know if it is possible in an eassy way, but, as I said, it could be amazing.
I don't know why, but the the free tags alpha is not doing as the tags alpha
I don't want to see warings by default, and I think that it will be cool if we just change the default option.
I think it could be amazing if we can specify in a parameter that we want to generate smooth curves.
When the position selected is top, the distance of the tags depends on the number of tags and this is not how it is supossed to work.
Peephole is supposed to be scaled with the thickness but I think it is not doing that.
Im thinking about adding utilities
folder with multiple methods to help us to work with opencv.
For example, you may want to get all images with a determinate extension in folder and all subdirectories.
Or maybe you want to do it, but separating it in multiple classes.
print('FPS: {}'.format(manager_cv2.get_fps()))
File "/usr/local/lib/python3.6/dist-packages/cv2_tools/Management.py", line 222, in get_fps
return round(self.count_frames / (self.final_time - self.initial_time),3)
TypeError: unsupported operand type(s) for -: 'NoneType' and 'float'
Right now we can add tags to polygons only if we attach a zone to them.
I want to be capable to add tags without a selection.
I think the easiest way to solve this problem is just to change the alpha value of the attached zone to 0, so it is completle invisible, while it exists (becouse, we need and want to have this rectangle, because it is necessary for selection the possition of each tag).
But I think, the better way to attack this problem is not saving the rectangle itself, just save the polygon, and make Utils.py generate the rectangle but only for the constraints algorithm.
Why the second idea could be better?
Because with the first option, we are drawing rectangles. Invisible ones, but at the end spending time in an unnecessary task.
Right now we only support rectangles, therefore we can create an object capable to receive coordinates of points and draw the complete shape.
For the first aproximation of tagging this shapes we are going to create virtual rectangles (not necessarily drawed). Therefore the tagging logic will work with this rectangle (ignoring all the points).
Example of output:
If all of this works well we can set a parameter to generate smooth curves:
We want to be capable to call all the methods just creating an object that manage most of the things for us.
What about, an option to select an area and show the tags inside it only if the mouse is on it.
I think the steps should be:
Right now we can call the method select_zone()
to draw a zone with his tags.
If you want to select more than a zone you need to call this method multiple times.
This is okay, but it is not perfect becouse the "intelligence" to position the tags don't ask the rest of the calls to that method.
Therefore, I think it is a good idea to create a new method called select_multiple_zone()
.
This method will try to posicionate correctly all the tags knowing the other zones.
Porbably we will need to add another library to do this: https://labix.org/python-constraint
I think it could be a really good idea if we allow the user to pass negative coordinates to the shape.
So, if we indicated a tag to be in the coordinates (-10,-10)
, what we want is to draw the tag in te bottom right corner, with ten pixels of distance with both edges.
If you want to do it by hand it is not that easy, so we can try to help.
Traceback (most recent call last):
File "/usr/local/lib/python3.5/dist-packages/cv2_tools/Storage.py", line 40, in json_unzip
compressed_dict = json.loads(compressed_dict)
File "/usr/lib/python3.5/json/init.py", line 312, in loads
s.class.name))
TypeError: the JSON object must be str, not 'bytes'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "send_test.py", line 145, in
load_video(sys.argv[2])
File "send_test.py", line 125, in load_video
storage_cv2 = StorageCV2(path='salida.json')
File "/usr/local/lib/python3.5/dist-packages/cv2_tools/Storage.py", line 120, in init
self.load_from_file(path)
File "/usr/local/lib/python3.5/dist-packages/cv2_tools/Storage.py", line 201, in load_from_file
self.complete_structure = json_unzip(json.load(json_file))
File "/usr/local/lib/python3.5/dist-packages/cv2_tools/Storage.py", line 42, in json_unzip
raise RuntimeError("Could interpret the unzipped contents")
RuntimeError: Could interpret the unzipped contents
Some times, if you try to execute cv2.imshow
, it will do it wrong, I found a way to solve it.
Just add cv2.waitKey(1)
(somewhere inside the main loop).
I wan't to make it invisible to the user.
This is very obvious, but it doesn't exist right now, so we need to work at it for sure.
When you are selecting items, you may want to select each class with a different color.
So it will be perfect if the library manage it for you (only if you specify that you want this functionality)
I think it could be a good idea if ManagerCV2 could support a list of paths or a list of cv2_frames, and not only an opened video.
Right tags, and left tags have also bugs.
Probably it will be the same as top tags.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.