Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

warpPerspetive keeps drawing image with black background #842

Open
DOEHOONLEE opened this issue Jan 20, 2022 · 1 comment
Open

warpPerspetive keeps drawing image with black background #842

DOEHOONLEE opened this issue Jan 20, 2022 · 1 comment

Comments

@DOEHOONLEE
Copy link

Hi!

I am new to opencv4nodejs and enjoying a lot processing images in different and fun ways.

However, I am having an issue with cv.warpPerspective.

With opencv.js copied from the openCV website and cv.warpPerspective allows me to get warped image with transparent/white background, but for some reason, I can't get it with opencv4nodejs.

I am getting an image drawn on a canvas so I converted it to base64 in order to make it into a Mat.

like cv.imdecodeAsync(Buffer.from(canvasInBase64, 'base64'))

then I have source and destination coordinates ready with new cv.Point2()

get it transformed with cv.getPerspectiveTransform(sourceCoordinates, destinationCoordinates)

and finally, warp it with mat.warpPerspective(transformData, new cv.Size(width, height))

Is there a way to get an image warped with transparent background with the codes above?

Thanks! Happy Coding!!

@ThornWalli
Copy link

I solved it by giving both images an alpha channel.

Example:

const newIm = im.cvtColor(cv.COLOR_RGB2RGBA)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants