Open CASCADE学习|显示文本

目录

1、修改代码

Viewer.h:

Viewer.cpp:

2、显示文本

OpenCasCade 你好啊

霜吹花落


1、修改代码

在文章《Open CASCADE学习|显示模型》基础上,增加部分代码,实现对文本显示的支持,具体如下:

Viewer.h:

//-----------------------------------------------------------------------------// Created on: 24 August 2017//-----------------------------------------------------------------------------// Copyright (c) 2017, Sergey Slyadnev (sergey.slyadnev@gmail.com)// All rights reserved.//// Redistribution and use in source and binary forms, with or without// modification, are permitted provided that the following conditions are met:////    * Redistributions of source code must retain the above copyright//      notice, this list of conditions and the following disclaimer.//    * Redistributions in binary form must reproduce the above copyright//      notice, this list of conditions and the following disclaimer in the//      documentation and/or other materials provided with the distribution.//    * Neither the name of the copyright holder(s) nor the//      names of all contributors may be used to endorse or promote products//      derived from this software without specific prior written permission.//// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND// ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED// WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE// DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE FOR ANY// DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES// (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;// LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND// ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.//-----------------------------------------------------------------------------#pragma once#ifdef _WIN32#include <Windows.h>#endif// Local includes#include "ViewerInteractor.h"// OpenCascade includes#include <TopoDS_Shape.hxx>#include <AIS_TextLabel.hxx>#include <WNT_Window.hxx>// Standard includes#include <vector>class V3d_Viewer;class V3d_View;class AIS_InteractiveContext;class AIS_ViewController;//-----------------------------------------------------------------------------//! Simple 3D viewer.class Viewer{public:    Viewer(const int left,        const int top,        const int width,        const int height);public:    Viewer& operator<<(const TopoDS_Shape& shape)    {        this->AddShape(shape);        return *this;    }    Viewer& operator<<(const Handle(AIS_TextLabel)& label)    {        this->AddLabel(label);        return *this;    }    void AddShape(const TopoDS_Shape& shape);    void AddLabel(const Handle(AIS_TextLabel)& label);    void StartMessageLoop();    void StartMessageLoop2();private:    static LRESULT WINAPI        wndProcProxy(HWND hwnd,            UINT message,            WPARAM wparam,            LPARAM lparam);    LRESULT CALLBACK        wndProc(HWND hwnd,            UINT message,            WPARAM wparam,            LPARAM lparam);    void init(const HANDLE& windowHandle);    /* API-related things */private:    std::vector<TopoDS_Shape> m_shapes; //!< Shapes to visualize.    std::vector<Handle(AIS_TextLabel)> m_labels; //!< Shapes to visualize.    /* OpenCascade's things */private:    Handle(V3d_Viewer)             m_viewer;    Handle(V3d_View)               m_view;    Handle(AIS_InteractiveContext) m_context;    Handle(WNT_Window)             m_wntWindow;    Handle(ViewerInteractor)       m_evtMgr;    /* Lower-level things */private:    HINSTANCE m_hInstance; //!< Handle to the instance of the module.    HWND      m_hWnd;      //!< Handle to the instance of the window.    bool      m_bQuit;     //!< Indicates whether user want to quit from window.};

Viewer.cpp:

//-----------------------------------------------------------------------------
// Created on: 24 August 2017
//-----------------------------------------------------------------------------
// Copyright (c) 2017, Sergey Slyadnev (sergey.slyadnev@gmail.com)
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are met:
//
//    * Redistributions of source code must retain the above copyright
//      notice, this list of conditions and the following disclaimer.
//    * Redistributions in binary form must reproduce the above copyright
//      notice, this list of conditions and the following disclaimer in the
//      documentation and/or other materials provided with the distribution.
//    * Neither the name of the copyright holder(s) nor the
//      names of all contributors may be used to endorse or promote products
//      derived from this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
// ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
// WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
// DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE FOR ANY
// DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
// (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
// LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
// ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//-----------------------------------------------------------------------------// Own include
#include "Viewer.h"// OpenCascade includes
#include <AIS_InteractiveContext.hxx>
#include <AIS_Shape.hxx>
#include <Aspect_DisplayConnection.hxx>
#include <Aspect_Handle.hxx>
#include <OpenGl_GraphicDriver.hxx>
#include <V3d_AmbientLight.hxx>
#include <V3d_DirectionalLight.hxx>
#include <V3d_View.hxx>
#include <V3d_Viewer.hxx>namespace {//! Adjust the style of local selection.//! \param[in] context the AIS context.void AdjustSelectionStyle(const Handle(AIS_InteractiveContext)& context){// Initialize style for sub-shape selection.Handle(Prs3d_Drawer) selDrawer = new Prs3d_Drawer;//selDrawer->SetLink(context->DefaultDrawer());selDrawer->SetFaceBoundaryDraw(true);selDrawer->SetDisplayMode(1); // ShadedselDrawer->SetTransparency(0.5f);selDrawer->SetZLayer(Graphic3d_ZLayerId_Topmost);selDrawer->SetColor(Quantity_NOC_GOLD);selDrawer->SetBasicFillAreaAspect(new Graphic3d_AspectFillArea3d());// Adjust fill area aspect.const Handle(Graphic3d_AspectFillArea3d)&fillArea = selDrawer->BasicFillAreaAspect();//fillArea->SetInteriorColor(Quantity_NOC_GOLD);fillArea->SetBackInteriorColor(Quantity_NOC_GOLD);//fillArea->ChangeFrontMaterial().SetMaterialName(Graphic3d_NOM_NEON_GNC);fillArea->ChangeFrontMaterial().SetTransparency(0.4f);fillArea->ChangeBackMaterial().SetMaterialName(Graphic3d_NOM_NEON_GNC);fillArea->ChangeBackMaterial().SetTransparency(0.4f);selDrawer->UnFreeBoundaryAspect()->SetWidth(1.0);// Update AIS context.context->SetHighlightStyle(Prs3d_TypeOfHighlight_LocalSelected, selDrawer);}
}//-----------------------------------------------------------------------------Viewer::Viewer(const int left,const int top,const int width,const int height): m_hWnd(NULL),m_bQuit(false)
{// Register the window class oncestatic HINSTANCE APP_INSTANCE = NULL;if (APP_INSTANCE == NULL){APP_INSTANCE = GetModuleHandleW(NULL);m_hInstance = APP_INSTANCE;WNDCLASSW WC;WC.cbClsExtra = 0;WC.cbWndExtra = 0;WC.hbrBackground = (HBRUSH)GetStockObject(BLACK_BRUSH);WC.hCursor = LoadCursor(NULL, IDC_ARROW);WC.hIcon = LoadIcon(NULL, IDI_APPLICATION);WC.hInstance = APP_INSTANCE;WC.lpfnWndProc = (WNDPROC)wndProcProxy;WC.lpszClassName = L"OpenGLClass";WC.lpszMenuName = 0;WC.style = CS_HREDRAW | CS_VREDRAW | CS_OWNDC;if (!RegisterClassW(&WC)){return;}}// Set coordinates for window's area rectangle.RECT Rect;SetRect(&Rect,left, top,left + width, top + height);// Adjust window rectangle.AdjustWindowRect(&Rect, WS_OVERLAPPEDWINDOW, false);// Create window.m_hWnd = CreateWindow(L"OpenGLClass",L"Quaoar >>> 3D",WS_OVERLAPPEDWINDOW,Rect.left, Rect.top, // Adjusted x, y positionsRect.right - Rect.left, Rect.bottom - Rect.top, // Adjusted width and heightNULL, NULL,m_hInstance,this);// Check if window has been created successfully.if (m_hWnd == NULL){return;}// Show window finally.ShowWindow(m_hWnd, TRUE);HANDLE windowHandle = (HANDLE)m_hWnd;this->init(windowHandle);
}//-----------------------------------------------------------------------------void Viewer::AddShape(const TopoDS_Shape& shape)
{m_shapes.push_back(shape);
}void Viewer::AddLabel(const Handle(AIS_TextLabel)& label)
{m_labels.push_back(label);
}
//-----------------------------------------------------------------------------//! Starts message loop.
void Viewer::StartMessageLoop()
{for (auto sh : m_shapes){Handle(AIS_Shape) shape = new AIS_Shape(sh);m_context->Display(shape, true);m_context->SetDisplayMode(shape, AIS_Shaded, true);// Adjust selection style.::AdjustSelectionStyle(m_context);// Activate selection modes.m_context->Activate(4, true); // facesm_context->Activate(2, true); // edges}MSG Msg;while (!m_bQuit){switch (::MsgWaitForMultipleObjectsEx(0, NULL, 12, QS_ALLINPUT, 0)){case WAIT_OBJECT_0:{while (::PeekMessage(&Msg, NULL, 0, 0, PM_REMOVE)){if (Msg.message == WM_QUIT)m_bQuit = true;// return;::TranslateMessage(&Msg);::DispatchMessage(&Msg);}}}}
}//! Starts message loop.
void Viewer::StartMessageLoop2()
{for (auto sh : m_labels){//Handle(AIS_Shape) shape = new AIS_Shape(sh);m_context->Display(sh,0);//m_context->SetDisplayMode(shape, AIS_Shaded, true);// Adjust selection style.::AdjustSelectionStyle(m_context);// Activate selection modes.m_context->Activate(4, true); // facesm_context->Activate(2, true); // edges}MSG Msg;while (!m_bQuit){switch (::MsgWaitForMultipleObjectsEx(0, NULL, 12, QS_ALLINPUT, 0)){case WAIT_OBJECT_0:{while (::PeekMessage(&Msg, NULL, 0, 0, PM_REMOVE)){if (Msg.message == WM_QUIT)m_bQuit = true;// return;::TranslateMessage(&Msg);::DispatchMessage(&Msg);}}}}
}//-----------------------------------------------------------------------------void Viewer::init(const HANDLE& windowHandle)
{static Handle(Aspect_DisplayConnection) displayConnection;//if (displayConnection.IsNull())displayConnection = new Aspect_DisplayConnection();HWND winHandle = (HWND)windowHandle;//if (winHandle == NULL)return;// Create OCCT viewer.Handle(OpenGl_GraphicDriver)graphicDriver = new OpenGl_GraphicDriver(displayConnection, false);m_viewer = new V3d_Viewer(graphicDriver);// Lightning.Handle(V3d_DirectionalLight) LightDir = new V3d_DirectionalLight(V3d_Zneg, Quantity_Color(Quantity_NOC_GRAY97), 1);Handle(V3d_AmbientLight)     LightAmb = new V3d_AmbientLight();//LightDir->SetDirection(1.0, -2.0, -10.0);//m_viewer->AddLight(LightDir);m_viewer->AddLight(LightAmb);m_viewer->SetLightOn(LightDir);m_viewer->SetLightOn(LightAmb);// AIS context.m_context = new AIS_InteractiveContext(m_viewer);// Configure some global props.const Handle(Prs3d_Drawer)& contextDrawer = m_context->DefaultDrawer();//if (!contextDrawer.IsNull()){const Handle(Prs3d_ShadingAspect)& SA = contextDrawer->ShadingAspect();const Handle(Graphic3d_AspectFillArea3d)& FA = SA->Aspect();contextDrawer->SetFaceBoundaryDraw(true); // Draw edges.FA->SetEdgeOff();// Fix for inifinite lines has been reduced to 1000 from its default value 500000.contextDrawer->SetMaximalParameterValue(1000);}// Main view creation.m_view = m_viewer->CreateView();m_view->SetImmediateUpdate(false);// Event manager is constructed when both contex and view become available.m_evtMgr = new ViewerInteractor(m_view, m_context);// Aspect window creationm_wntWindow = new WNT_Window(winHandle);m_view->SetWindow(m_wntWindow, nullptr);//if (!m_wntWindow->IsMapped()){m_wntWindow->Map();}m_view->MustBeResized();// View settings.m_view->SetShadingModel(V3d_PHONG);// Configure rendering parametersGraphic3d_RenderingParams& RenderParams = m_view->ChangeRenderingParams();RenderParams.IsAntialiasingEnabled = true;RenderParams.NbMsaaSamples = 8; // Anti-aliasing by multi-samplingRenderParams.IsShadowEnabled = false;RenderParams.CollectedStats = Graphic3d_RenderingParams::PerfCounters_NONE;
}//-----------------------------------------------------------------------------LRESULT WINAPI Viewer::wndProcProxy(HWND   hwnd,UINT   message,WPARAM wparam,LPARAM lparam)
{if (message == WM_CREATE){// Save pointer to our class instance (sent on window create) to window storage.CREATESTRUCTW* pCreateStruct = (CREATESTRUCTW*)lparam;SetWindowLongPtr(hwnd, int(GWLP_USERDATA), (LONG_PTR)pCreateStruct->lpCreateParams);}// Get pointer to our class instance.Viewer* pThis = (Viewer*)GetWindowLongPtr(hwnd, int(GWLP_USERDATA));return (pThis != NULL) ? pThis->wndProc(hwnd, message, wparam, lparam): DefWindowProcW(hwnd, message, wparam, lparam);
}//-----------------------------------------------------------------------------//! Window procedure.
LRESULT Viewer::wndProc(HWND   hwnd,UINT   message,WPARAM wparam,LPARAM lparam)
{if (m_view.IsNull())return DefWindowProc(hwnd, message, wparam, lparam);switch (message){case WM_PAINT:{PAINTSTRUCT aPaint;BeginPaint(m_hWnd, &aPaint);EndPaint(m_hWnd, &aPaint);m_evtMgr->ProcessExpose();break;}case WM_SIZE:{m_evtMgr->ProcessConfigure();break;}case WM_MOVE:case WM_MOVING:case WM_SIZING:{switch (m_view->RenderingParams().StereoMode){case Graphic3d_StereoMode_RowInterlaced:case Graphic3d_StereoMode_ColumnInterlaced:case Graphic3d_StereoMode_ChessBoard:{// track window moves to reverse stereo pairm_view->MustBeResized();m_view->Update();break;}default:break;}break;}case WM_KEYUP:case WM_KEYDOWN:{const Aspect_VKey vkey = WNT_Window::VirtualKeyFromNative((int)wparam);//if (vkey != Aspect_VKey_UNKNOWN){const double timeStamp = m_evtMgr->EventTime();if (message == WM_KEYDOWN){m_evtMgr->KeyDown(vkey, timeStamp);}else{m_evtMgr->KeyUp(vkey, timeStamp);}}break;}case WM_LBUTTONUP:case WM_MBUTTONUP:case WM_RBUTTONUP:case WM_LBUTTONDOWN:case WM_MBUTTONDOWN:case WM_RBUTTONDOWN:{const Graphic3d_Vec2i pos(LOWORD(lparam), HIWORD(lparam));const Aspect_VKeyFlags flags = WNT_Window::MouseKeyFlagsFromEvent(wparam);Aspect_VKeyMouse button = Aspect_VKeyMouse_NONE;//switch (message){case WM_LBUTTONUP:case WM_LBUTTONDOWN:button = Aspect_VKeyMouse_LeftButton;break;case WM_MBUTTONUP:case WM_MBUTTONDOWN:button = Aspect_VKeyMouse_MiddleButton;break;case WM_RBUTTONUP:case WM_RBUTTONDOWN:button = Aspect_VKeyMouse_RightButton;break;}if (message == WM_LBUTTONDOWN|| message == WM_MBUTTONDOWN|| message == WM_RBUTTONDOWN){SetFocus(hwnd);SetCapture(hwnd);if (!m_evtMgr.IsNull())m_evtMgr->PressMouseButton(pos, button, flags, false);}else{ReleaseCapture();if (!m_evtMgr.IsNull())m_evtMgr->ReleaseMouseButton(pos, button, flags, false);}m_evtMgr->FlushViewEvents(m_context, m_view, true);break;}case WM_MOUSEWHEEL:{const int    delta = GET_WHEEL_DELTA_WPARAM(wparam);const double deltaF = double(delta) / double(WHEEL_DELTA);//const Aspect_VKeyFlags flags = WNT_Window::MouseKeyFlagsFromEvent(wparam);//Graphic3d_Vec2i pos(int(short(LOWORD(lparam))), int(short(HIWORD(lparam))));POINT cursorPnt = { pos.x(), pos.y() };if (ScreenToClient(hwnd, &cursorPnt)){pos.SetValues(cursorPnt.x, cursorPnt.y);}if (!m_evtMgr.IsNull()){m_evtMgr->UpdateMouseScroll(Aspect_ScrollDelta(pos, deltaF, flags));m_evtMgr->FlushViewEvents(m_context, m_view, true);}break;}case WM_MOUSEMOVE:{Graphic3d_Vec2i pos(LOWORD(lparam), HIWORD(lparam));Aspect_VKeyMouse buttons = WNT_Window::MouseButtonsFromEvent(wparam);Aspect_VKeyFlags flags = WNT_Window::MouseKeyFlagsFromEvent(wparam);// don't make a slide-show from input events - fetch the actual mouse cursor positionCURSORINFO cursor;cursor.cbSize = sizeof(cursor);if (::GetCursorInfo(&cursor) != FALSE){POINT cursorPnt = { cursor.ptScreenPos.x, cursor.ptScreenPos.y };if (ScreenToClient(hwnd, &cursorPnt)){// as we override mouse position, we need overriding also mouse statepos.SetValues(cursorPnt.x, cursorPnt.y);buttons = WNT_Window::MouseButtonsAsync();flags = WNT_Window::MouseKeyFlagsAsync();}}if (m_wntWindow.IsNull() || (HWND)m_wntWindow->HWindow() != hwnd){// mouse move events come also for inactive windowsbreak;}if (!m_evtMgr.IsNull()){m_evtMgr->UpdateMousePosition(pos, buttons, flags, false);m_evtMgr->FlushViewEvents(m_context, m_view, true);}break;}default:{break;}case WM_DESTROY:m_bQuit = true;}return DefWindowProc(hwnd, message, wparam, lparam);
}

2、显示文本

OpenCasCade 你好啊

#include "TCollection_ExtendedString.hxx"#include "Resource_Unicode.hxx"#include "AIS_TextLabel.hxx"#include "AIS_InteractiveContext.hxx"#include"Viewer.h"int main() {    TCollection_ExtendedString tostr;    Standard_CString str = "OpenCasCade 你好啊";    Resource_Unicode::ConvertGBToUnicode(str, tostr);    Handle(AIS_TextLabel) aLabel = new AIS_TextLabel();    aLabel->SetText(tostr);    aLabel->SetColor(Quantity_NOC_RED);    aLabel->SetFont("SimHei");    Viewer vout(50, 50, 500, 500);    vout << aLabel;    vout.StartMessageLoop2();    return 0;    }

霜吹花落

#include "TCollection_ExtendedString.hxx"#include "Resource_Unicode.hxx"#include "AIS_TextLabel.hxx"#include "AIS_InteractiveContext.hxx"#include"Viewer.h"int main() {    TCollection_ExtendedString tostr;    Standard_CString str = "霜吹花落";    Resource_Unicode::ConvertGBToUnicode(str, tostr);    Handle(AIS_TextLabel) aLabel = new AIS_TextLabel();    aLabel->SetPosition(gp_Pnt(0, 0, 0));    aLabel->SetText(tostr);    aLabel->SetHJustification(Graphic3d_HTA_CENTER);    aLabel->SetVJustification(Graphic3d_VTA_CENTER);    aLabel->SetHeight(50);    aLabel->SetZoomable(false);//如果允许缩放,你会发现放大后字太难看了    aLabel->SetAngle(0);    aLabel->SetColor(Quantity_NOC_YELLOW);    aLabel->SetFont("SimHei");//一定要设置合适的字体,不然不能实现功能    //如果有一天你需要鼠标选中文本时,下面代码有用,高亮文本    Handle(Prs3d_Drawer) aStyle = new Prs3d_Drawer(); // 获取高亮风格    aLabel->SetHilightAttributes(aStyle);    aStyle->SetMethod(Aspect_TOHM_COLOR);    aStyle->SetColor(Quantity_NOC_RED);    // 设置高亮颜色    aStyle->SetDisplayMode(1); // 整体高亮    aLabel->SetDynamicHilightAttributes(aStyle);    Viewer vout(50, 50, 500, 500);    vout << aLabel;    vout.StartMessageLoop2();    return 0;    }

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.rhkb.cn/news/285737.html

如若内容造成侵权/违法违规/事实不符,请联系长河编程网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

思腾合力携AI服务器亮相第二十一届中国电博会

博会已发展成为海峡两岸IT产业界规模最大、参展企业最多、产业配套最全的知名展会之一&#xff0c;今年以“数字赋能、创新制造”为主题&#xff0c;线下参展企业达400家。展会期间&#xff0c;举办了论坛与产业洽谈会等系列活动&#xff0c;进一步推动了两岸电子信息产业融合发…

进程和线程,线程实现的几种基本方法

什么是进程&#xff1f; 我们这里学习进程是为了后面的线程做铺垫的。 一个程序运行起来&#xff0c;在操作系统中&#xff0c;就会出现对应的进程。简单的来说&#xff0c;一个进程就是跑起来的应用程序。 在电脑上我们可以通过任务管理器可以看到&#xff0c;跑起来的应用程…

redis在springboot项目中的应用

一&#xff0c;将查询结果放到redis中作为缓存&#xff0c;减轻mysql的压力。 只有在数据量大的时候&#xff0c;查询速度慢的时候才有意义。 本次测试的数据量为百万级别。 测试代码: 功能为根据昵称进行模糊匹配。 GetMapping("/get-by-nick")public String get…

数字保护的壁垒:探索 Web3 的网络安全

引言 随着数字化时代的到来&#xff0c;网络安全问题日益突出&#xff0c;而Web3作为新一代互联网的演进形态&#xff0c;其网络安全问题备受关注。本文将深入探讨Web3的网络安全特点、挑战以及应对策略&#xff0c;帮助读者更好地了解数字保护的壁垒与Web3的关系&#xff0c;…

ctfshow web入门 反序列化

254 分析代码&#xff1a; 如果用户名和密码参数都存在&#xff0c;脚本会创建一个 ctfShowUser 类的实例 $user。 接着&#xff0c;调用 $user->login($username, $password) 方法尝试登录。如果登录成功&#xff08;即用户名和密码与类中的默认值匹配&#xff09;&#…

vscode中导入#include “opencv2/opencv.hpp“

鼠标放到上面 点击快速修复 1.img.cpp // 图片的读取和显示 // 导入opencv头文件 #include "opencv2/opencv.hpp" #include <iostream>int main(int argc, char** argv) {// 读取图片&#xff0c;mat是matrix的缩写&#xff0c;是一个矩阵&#xff0c;类似与n…

睿眼(Realeye)视觉识别模型训练全流程心得分享

睿眼&#xff08;Realeye&#xff09;是一款集智能采集、识别、定位、抓取、视控全流程为一体的 AI 产品&#xff0c; 以其 AI 算法结合机械臂硬件实现对万事万物的定位抓取功能&#xff0c;能够实现对任意目标物从图 片采集、标注到模型训练和抓取。通过人性化的交互方式、易操…

自然语言处理: 第十九章LoRAQLoRA微调技巧

论文地址&#xff1a;使用低秩自适应 &#xff08;LoRA&#xff09; 进行参数高效LLM微调 - Lightning AI — Parameter-Efficient LLM Finetuning With Low-Rank Adaptation (LoRA) - Lightning AI 本篇文章是由位来自威斯康星大学麦迪逊分校的统计学助理教授Sebastian Raschk…

C++除了Qt还有什么GUI库?

C除了Qt还有什么GUI库&#xff1f; 先&#xff0c;不要折腾&#xff0c;不要想着用 C 来做 App 类的 GUI 开发。 所以你问用 c gui 库&#xff0c;本来确实有很多&#xff0c;但是经过几十年的沉淀&#xff0c;最后只留下一个 qt quick 和其他特殊需求的库&#xff08;包括 qt…

西圣、漫步者、万魔开放式耳机如何?甄选机型实测对比测评

无论是通勤、工作还是休闲时光&#xff0c;耳机总能为我们带来沉浸式的音乐体验。近年来&#xff0c;开放式耳机以其独特的优势逐渐受到市场的青睐&#xff0c;其中西圣、漫步者、万魔等品牌在市场上相当火热&#xff0c;那这三款开放式耳机的实际到底如何&#xff0c;还是有许…

nodeJs中实现连表查询

nodeJs中实现连表查询 router.post(/getOrder, async function(req, res, next) {let userId req.body.phone;let sql select * from orders where userId?;let orders await new Promise((resolve, reject) > {connection.query(sql, [userId], function(error, resul…

Python灰帽子网络安全实践

教程介绍 旨在降低网络防范黑客的入门门槛&#xff0c;适合所有中小企业和传统企业。罗列常见的攻击手段和防范方法&#xff0c;让网站管理人员都具备基本的保护能力。Python 编程的简单实现&#xff0c;让网络运维变得更简单。各种黑客工具的理论和原理解剖&#xff0c;让人知…

详解“外卡收单”系统(1)

近年来&#xff0c;随着跨境贸易和服务的不断发展&#xff0c;外卡收单行业展现出新的发展态势。随着越来越多外国人在中国消费&#xff0c;中国商家为满足海外消费者需求开始接受国际信用卡支付。根据官方数据显示&#xff0c;截至2023年11月&#xff0c;上海的外卡POS机已超过…

【C++】vector容器初步模拟

送给大家一句话&#xff1a; 努力一点&#xff0c;漂亮—点&#xff0c;阳光一点。早晚有一天&#xff0c;你会惊艳了时光&#xff0c;既无人能替&#xff0c;又光芒万丈。 vector容器初步模拟 1 认识vector开始了解底层实现 2 开始实现成员变量构造函数 析构函数尾插迭代器插入…

集成学习 | 集成学习思想:Boosting思想 | XGBoost算法、LightGBM算法

目录 一. XGBoost 算法1. XGBoost 算法流程2. XGBoost 算法评价 二. LightGBM 算法2. LightGBM 算法优势 上一篇文章中&#xff0c;我们了解了Boosting思想的两种算法&#xff1a;Adboost和GBDT&#xff1b;其中对于GBDT算法&#xff0c;存在两种改进&#xff0c;即&#xff1a…

外包干了20天,技术退步明显.......

先说一下自己的情况&#xff0c;大专生&#xff0c;21年通过校招进入杭州某软件公司&#xff0c;干了接近2年的功能测试&#xff0c;今年年初&#xff0c;感觉自己不能够在这样下去了&#xff0c;长时间呆在一个舒适的环境会让一个人堕落! 而我已经在一个企业干了2年的功能测试…

1分钟带你学会使用Python操作 xlsx 文件绘制面积图

​我们工作中经常要处理海量的数据&#xff0c;如果没有一个直观的可视化工具&#xff0c;怎么可能一眼就看出数据背后的故事呢&#xff1f;数据可视化显得越来越重要&#xff0c;数据分析已经成了现代人必备的技能。 今天来和大家分享一个超有趣的数据可视化方法——绘制面积…

Redis中文乱码问题

最近排查问题&#xff0c;发现之前的开发将日志写在redis缓存中&#xff08;不建议这样做&#xff09;&#xff0c;我在查看日志的时候发现没办法阅读&#xff0c;详细是这样的&#xff1a; 查阅资料后发现是进制问题&#xff0c;解决方法是启动客户端的时候将redis-cli改为red…

流畅的 Python 第二版(GPT 重译)(四)

第二部分&#xff1a;函数作为对象 第七章&#xff1a;函数作为一等对象 我从未认为 Python 受到函数式语言的重大影响&#xff0c;无论人们说什么或想什么。我更熟悉命令式语言&#xff0c;如 C 和 Algol 68&#xff0c;尽管我将函数作为一等对象&#xff0c;但我并不认为 Py…

【机器学习】机器学习是什么?

文章目录 前言 机器学习 序列学习和对抗学习有什么不同 总结 前言 在当今快速发展的科技时代&#xff0c;人工智能已经成为推动社会进步的重要力量。机器学习&#xff0c;作为人工智能领域的一个重要分支&#xff0c;它的核心能力在于使计算机系统能够从数据中学习规律&…