Code Monkey home page Code Monkey logo

Comments (7)

chenjie26 avatar chenjie26 commented on August 14, 2024 2

i know what's wrong. my png image has problem.
Thank you again.

from opencv4nodejs.

justadudewhohacks avatar justadudewhohacks commented on August 14, 2024

It is not really clear to me what you are trying to achieve and what you expect the output to be. Could you please give some more details?

from opencv4nodejs.

chenjie26 avatar chenjie26 commented on August 14, 2024

getRegion will return a Mat pointing to the subregion, meaning if you change the data of the "region" Mat, the changes will reflect on the original Mat "mat".

i just want to know copyTo function can be change orignal Mat?.

in opencv3 C++

cv::Mat image = cv::imread("D:/imagewarping/testresult/hansome.jpg");
cv::Mat logo = cv::imread("D:/imagewarping/testresult/trans.jpg");
cv::Mat mask = cv::imread("D:/imagewarping/testresult/trans.jpg", 0);
cv::Mat imageROI;
imageROI = image(cv::Rect(182, 63, 215, 235));
logo.copyTo(imageROI, mask);
cv::namedWindow("result");
cv::imshow("result", image);

now i want to do something like C++ Code can do.

my english is so poor. sorry

from opencv4nodejs.

justadudewhohacks avatar justadudewhohacks commented on August 14, 2024

I see. CopyTo should work as expected. I think the problem here is that newFrame.cvtColor returns a new Mat (e.g. a new copy) as well.

In order to copy it into the "newFrame" try the following:

let newFrame = frame.getRegion(new cv.Rect(400, 0, 480, 720)).cvtColor(cv.COLOR_BGR2RGBA);
let imageROI = newFrame.getRegion(new cv.Rect(0, 0, addMat.cols, addMat.rows));
let cpTo = addMat.copyTo(imageROI, mask);

from opencv4nodejs.

chenjie26 avatar chenjie26 commented on August 14, 2024

ok this is work .
thank you very much.
the last quesiotn.
my '/assets/images/1_4.png' has Transparent part。
but when i do addMat.copyTo. Transparent part change to white color.

from opencv4nodejs.

justadudewhohacks avatar justadudewhohacks commented on August 14, 2024

Hmm actually I am not sure how to process images with transparency in OpenCV. How do you know the transparent part is changed to white, isn't the transparency expressed by the alpha channel in RGBA? Maybe imshow can not display RGBA images properly, is it also white when saving the output with imsave?

from opencv4nodejs.

chenjie26 avatar chenjie26 commented on August 14, 2024

OK. i use canvas to display image.
ctx.putImageData(imgData, 0, 0).
in canvas display white.

from opencv4nodejs.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.