Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
536 views
in Technique[技术] by (71.8m points)

iphone - How to merge the perspective image(3D Transform)?

enter image description here

How to merge these two images(see attached image).I am using the below code. Its working for ordinary images not for 3D transform images. How to handle this issue. I have searched lot of times still not getting the proper result. Please help me. Thanks in advance.

UIImage *mergedImage;
UIGraphicsBeginImageContext(backgroundImageView.frame.size);
[backgroundImageView.layer  renderInContext:UIGraphicsGetCurrentContext()]; //bacgroundImageView here
mergedImage = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

You could create a CGImageRef that contain the distorted image to put on top, (with the background of that image being 0% alpha) that way you could blend the images using your above code.

So what you are truly looking for is how to apply a 3D transform to an image. More precisely, as you are looking for "perspective" in you own words, you are looking on how to warp an homography to an image.

The CoreImage programming guide specify that CIPerspectiveTransform is the way to go, unfortunately for you this is not available on iOS as of iOS 5.1.

So you are left with a few choices :

  • If you want to display only the result blend and not manipulate it, you can use two UIImageViews on top of each other, the one containing the perspective image being transformed using a cleverly designed CATransform3D

  • If you absolutely need to blend the images, you will need to use another framework such as OpenCV (warpPerspective()is the function you are looking for) or OpenGL ES


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...