Visual Studio2022 opencv4.12编译viz功能注意

Visual Studio2022 opencv编译viz功能注意

with_vtk选择之后,才会有下面的viz选项

编译完成后vtk的dll也要复制到和opencv中的dll一起

c++ opencv viz测试代码

cpp 复制代码
#include <opencv2/viz.hpp>
#include <opencv2/core.hpp>
#include <iostream>

int main()
{
    // 创建一个Viz窗口
    cv::viz::Viz3d window("Viz Test");

    // 创建一个坐标系
    cv::viz::WCoordinateSystem coord(1.0);
    window.showWidget("Coordinate", coord);

    // 创建一个球体
    cv::Point3d sphere_center(0.0, 0.0, 0.0);
    double sphere_radius = 0.2;
    cv::viz::WSphere sphere_widget(sphere_center, sphere_radius, 10, cv::viz::Color::red());
    window.showWidget("Sphere", sphere_widget);

    // 创建一个立方体
    cv::Affine3d cube_pose = cv::Affine3d().translate(cv::Vec3d(0.5, 0.5, 0.0));
    cv::viz::WCube cube_widget(cv::Point3f(-0.1f, -0.1f, -0.1f), cv::Point3f(0.1f, 0.1f, 0.1f), true, cv::viz::Color::blue());
    window.showWidget("Cube", cube_widget, cube_pose);

    // 设置摄像机
    window.setViewerPose(cv::viz::makeCameraPose(cv::Vec3d(1,1,1), cv::Vec3d(0,0,0), cv::Vec3d(0,0,1)));

    // 主循环
    while (!window.wasStopped())
    {
        window.spinOnce(1, true);
    }

    return 0;
}
相关推荐
liufeiyu19761 天前
VS 2026 升级后出现错误: 找不到指定的 SDK“Microsoft.NET.Sdk”
visual studio·vs 2026
霍霍的袁1 天前
【C++】map 和 set 的使用 | 从用法到底层
开发语言·c++·学习·visual studio
2501_915909061 天前
移动端开发工具链怎么组合比较好,iOS、Android、跨端三套配置方案
ide·vscode·ios·objective-c·个人开发·swift·敏捷流程
2501_915918412 天前
iOS编程用什么软件好?主流工具Xcode、AppCode、CodeRunner与新兴快蝎对比
ide·vscode·ios·objective-c·个人开发·swift·敏捷流程
VIP_CQCRE2 天前
在 Visual Studio 里接入 Ace Data Cloud:让 AI 编程助手直接用上 OpenAI 兼容接口
openai·ai编程·开发工具·visual studio·acedatacloud
VIP_CQCRE2 天前
在 Visual Studio 里接入 AI 编程助手:用 Ace Data Cloud 打通 OpenAI 兼容接口与 LMLocal
openai·ai编程·visual studio·acedatacloud·lmlocal
free-elcmacom2 天前
发际线警告!手撕《C陷阱与缺陷》终极 BOSS:signal 函数与 typedef 魔法
c语言·开发语言·visual studio code·visual studio
VIP_CQCRE2 天前
Visual Studio 也能丝滑接入大模型:用 Ace Data Cloud + LMLocal 打造 AI 编程体验
ai·大模型·visual studio·ace data cloud·lmlocal
千谦阙听2 天前
【 C++篇】:模板初阶——泛型编程、函数模板与类模板
开发语言·c++·学习·visual studio
滕州市燕猫虎计算机科技工作室个体工商户3 天前
IDEA:Command line is too long
java·ide·intellij-idea