- mongodb - 在 MongoDB mapreduce 中,如何展平值对象?
- javascript - 对象传播与 Object.assign
- html - 输入类型 ="submit"Vs 按钮标签它们可以互换吗?
- sql - 使用 MongoDB 而不是 MS SQL Server 的优缺点
我想知道如何在OpenCV中绘制半透明的形状,类似于下图(来自http://tellthattomycamera.wordpress.com/)
我不需要那些花哨的圆圈,但我希望能够绘制一个矩形,例如,在 3 channel 彩色图像上并指定矩形的透明度,例如
rectangle (img, Point (100,100), Point (300,300), Scalar (0,125,125,0.4), CV_FILLED);
其中 0,125,125
是矩形的颜色,0.4
指定透明度。然而,OpenCV 并没有将此功能内置到其绘图功能中。如何在 OpenCV 中绘制形状,以便通过该形状部分看到正在绘制的原始图像?
最佳答案
下图说明了使用 OpenCV 的透明度。您需要在图像和矩形之间进行 alpha 混合。下面是执行此操作的一种方法的代码。
#include <opencv2/core/core.hpp>
#include <opencv2/highgui/highgui.hpp>
int main( int argc, char** argv )
{
cv::Mat image = cv::imread("IMG_2083s.png");
cv::Mat roi = image(cv::Rect(100, 100, 300, 300));
cv::Mat color(roi.size(), CV_8UC3, cv::Scalar(0, 125, 125));
double alpha = 0.3;
cv::addWeighted(color, alpha, roi, 1.0 - alpha , 0.0, roi);
cv::imshow("image",image);
cv::waitKey(0);
}
关于c++ - 如何创建一个半透明的形状?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24480751/
我在 NSWindow 中有一个 NSView,NSWindow 是标准的 Mac 灰色/米色。 我想让 NSView 稍微半透明和灰色(例如 alpha 为 0.2 的灰色),以便 NSWindow
我对 openGL 中的 alpha 混合有疑问... 我尝试了一些绘制透明对象的方法...通过在绘制透明面之前禁用 GL_DEPTH_TEST 并在绘制透明面后再次重新启用 GL_DEPTH_TES
我将导航栏自定义为清除。所以我将backgroundImage设置为UIImage()并且isTranslucent = true。所以我遇到的问题是:这就是我在 xib 中设置的。现在 TopCon
我一直在研究这个,似乎唯一的方法是使用 UIActionSheet,问题是我的 UIActionSheet 只覆盖了一半的屏幕,我的代码是: MyViewController *myVC = [[my
我希望在我的主要 Activity 中使用半透明的状态栏和导航栏,而所有其他 Activity 都使用 Material 设计。 到目前为止我得到的是: if (Build.VERSION.SDK_I
我可以在不使用私有(private)方法等的情况下获得对 UIAlertView 的 backgroundImageView 的引用。但是我的 alpha 设置为 1.0 被忽略了。控件仍然有点半透明
我正在研究 UIWebView,我想要的是 webView 不要过度说唱 View 。 所以这就是问题所在。我设置了 UIWebView ,状态栏覆盖在内容上。 我该如何处理?我在制作 UIImage
我正在为一款小型 2d 游戏在其他图像之上绘制半透明图像。目前要混合图像,我正在使用此处找到的公式:https://en.wikipedia.org/wiki/Alpha_compositing#Al
我正在尝试将 Splash Screen 4 制作成 Win 应用程序。 我的设置: 表单边框样式设置为无。起始位置是屏幕中心。表单的背景图像设置为 PNG 文件,具有圆形边缘和“内置”投影。 在我设
(此问题发生在使用 Java 1.7.0_45 的 Mac OS X 10.10 上。在使用 Java 1.7.0_55 的 Windows 7 上我没有遇到此问题。) 我有一个半透明的“始终在最前面
如果您知道学习如何使用 Adobe Flash 为 iPhone 应用程序甚至 Air 应用程序创建此类效果的任何良好起点,那将会有很大帮助。 具体来说,我希望它不保存叠加层,只在用户从相机拍摄图
我有以下行: label.setBackground(new java.awt.Color(0, 150, 0, 50)); 我将它放在 MouseAdapter 中的 mouseRe
我正在制作幻灯片。我希望导航栏看起来与照片应用程序中的一样。我如何获得这种透明度? 我试过: - (void)drawRect:(CGRect)rect { [[UIColor clearCo
我试图在半透明的 div 上获取文本。这是在 Chrome 中,如果相关(即 Chrome 错误)。出于某种原因,每当文本位于 div 顶部(移动到负边距顶部)时,它也是部分透明的。 HTML 如下(
我在 NSVisualEffectView 上有 2 个 NSButton。第一个按钮图像是系统 NSEnterFullScreenTemplate 图像。第一个按钮上的图像是半透明的。 在第二个按钮
我想在RelativeLayout中创建一个RelativeLayout半透明。 它是页脚的项目。它始终可见,但我只想使其黑色的透明度为 50%。 我尝试过使用#11000000 Alpha chan
我正在尝试使用 Qt (C++) 应用程序跨操作系统完成以下任务。运行该程序后,会弹出一个新窗口,一个全屏 QWidget。现在我希望它是透明的/透明的,这样用户就不会真正看到它。在这个“层”上,用户
所以,我的目标是绘制具有半透明像素的 Sprite 。 首先,我使用仅渲染不透明像素的着色器渲染 Sprite 。然后,我禁用深度缓冲区写入并使用仅渲染半透明(或透明 Sprite )的着色器渲染相同
CSS .popup { z-index: 10000; filter: alpha(opacity=40); -moz-opacity: .40; backgroun
我正在尝试创建一个 lightbox effect在我的应用程序中。为实现这一点,我有一个 UserControl,其中一个面板代表半透明覆盖层,另一个面板托管所有必要的内容。 当我显示此 UserC
我是一名优秀的程序员,十分优秀!