Comments (6)
When I transform the eyes, I want only the eyes to be transformed, not the entire image.
from pychubby.
Hey there! And thank you for your interest!
That is actually a great question:) pychubby
is built on top of a "4 corners logic". That means that the 4 corners will never be displaced. However, very often points on the edges are going to be displaced and it will lead to these black regions. Note that if it was not the case even weirder artefacts might show up.
Anyway, possible solutions
- Just crop the final image so that the black regions on the edges are not visible
- Get all the perfectly black pixels (RGB=(0, 0, 0)) and replace them with some other color. A cleaner way of doing this would be passing a custom color in
cv.remap
when doing the warping.
Line 247 in 3d7916f
- Completely change the logic of
pychubby
and make sure that pixels on the edge of the image are not displaced
I would go for the first option:)
Hope that helps:)
from pychubby.
Thank you for answer. Do you know how to prevent the pixels on the edges from being deformed?
Methods 1 and 2 do not seem to be able to solve my problem now.
from pychubby.
Well, you would need to modify the source code. See below exactly the lines which implement the "fixed points" logic. Currently, it only "anchors" the 4 corners.
Lines 60 to 68 in 3d7916f
See below a sketch of a possible change
I guess you would have to play around and experiment a bit and see for yourself. You can add as many fixed points as you want. Note that by specifying these fixed points you are basically forcing the displacement at those given points to be 0.
Hope that makes sense:)
from pychubby.
Transforming by adding anchor points at 50px spacing to each corner solved the problem. Thank you so very much.
corners_list = []
corners_list.append([0, 0])
corners_list.append([0, shape[0] -1]) # 0,y
corners_list.append([shape[1] -1, 0]) # x,0
corners_list.append([shape[1] -1, shape[0] -1]) # x,y
for i in range(1, shape[0]-1, 50):
corners_list.append([0,i])
corners_list.append([shape[1]-1,i])
for i in range(1, shape[1]-1, 50):
corners_list.append([i,0])
corners_list.append([i,shape[0]-1])
# print(shape[0], shape[1])
# print(corners_list)
if anchor_corners:
corners = np.array(corners_list)
new_points = np.vstack([new_points, corners])
old_points = np.vstack([old_points, corners])
points_delta_x = np.concatenate([points_delta_x, [0 for i in range(len(corners_list))]])
points_delta_y = np.concatenate([points_delta_y, [0 for i in range(len(corners_list))]])
from pychubby.
Great!
from pychubby.
Related Issues (19)
- just trying to store a readme image HOT 1
- Better error message when estimate class method fails
- Cmake a required dependency on osx HOT 2
- Neural network-based programs can do better HOT 3
- Define new actions HOT 5
- "shape_predictor_68_face_landmarks.dat" looks like under non-commercial license. HOT 1
- Error on performing action HOT 1
- TypeError: tuple indices must be integers or slices, not str HOT 4
- how to move landmark points.. pixel unit? HOT 1
- Make warping faster for big images HOT 3
- .
- Realtime warping HOT 2
- Use pychubby in android using Chaquopy sdk HOT 21
- Implement inversion of DF HOT 1
- Set python_requires in setup.py HOT 3
- Show a default in CLI
- Better error message when standard action applied on LandmarkFaces
- Fix code typos in docs (visualize -> visualization)
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from pychubby.