海康威视相机-LINUX SDK 开发

硬件与环境

mvs

相机: MV-CS020-10GC
系统:UBUNTU 22.04
语言:C++
工具:cmake
海康官网下载SDK
在这里插入图片描述

在这里插入图片描述
运行下面的命令进行安装

sudo dpkg -i  MVSXXX.deb

安装完成后从在/opt/MVS 路径下就有了相关的库,实际上我们开发的时候只需要lib和include。有兴趣的同学也可以尝试以下Samples的例子。make一下就能生成可执行文件。如果make报错,可能环境变量没有设置好,到bin文件夹下把那几个设置环境变量的shell脚本运行一下再试一试。

make

在这里插入图片描述
这里是我运行了/opt/MVS/Samples/64/Display下的例子。

在这里插入图片描述

开发

实际上我们开发的时候只需要目录/opt/MVS/lib和/opt/MVS/include下的文件。他们是海康提供的链接库。所以我们在写程序的时候链接到海康的库,我们就能调用海康官方的接口了。

我将海康的库放在我工程的3rdPartys下,这样就移植到其他电脑上会比较方便。

add_library(cameraAPISHARED
)
# Define preprocessor macro for exporting symbols on Windowsif(WIN32)target_compile_definitions(cameraAPI PRIVATE cameraAPI_EXPORTS)
endif()message( target name: cameraAPI )target_include_directories(cameraAPI  PRIVATE${OpenCV_INCLUDE_DIRS}./include./3rdPartys/mvsinclude
)target_sources(cameraAPI PRIVATE./src/edge_camera.cpp
)target_link_directories(cameraAPI  PUBLIC${OpenCV_LIBS}./3rdPartys/mvslib/64
)target_link_libraries(cameraAPI  PRIVATE${OpenCV_LIBS}MvCameraControlpthread
)

主要的程序

//
// Created by zc on 8/24/23.
//
#include "edge_camera.h"EDGE_CAMERA::EDGE_CAMERA() {std::cout<<"EDGE_CAMERA BEGIN!"<<std::endl;
}EDGE_CAMERA::~EDGE_CAMERA(){std::cout<<"EDGE_CAMERA FINISH!"<<std::endl;
}// print the discovered devices' information
void EDGE_CAMERA::PrintDeviceInfo(MV_CC_DEVICE_INFO* pstMVDevInfo)
{if (nullptr == pstMVDevInfo){printf("    NULL info.\n\n");return;}if (MV_GIGE_DEVICE == pstMVDevInfo->nTLayerType){unsigned int nIp1 = ((pstMVDevInfo->SpecialInfo.stGigEInfo.nCurrentIp & 0xff000000) >> 24);unsigned int nIp2 = ((pstMVDevInfo->SpecialInfo.stGigEInfo.nCurrentIp & 0x00ff0000) >> 16);unsigned int nIp3 = ((pstMVDevInfo->SpecialInfo.stGigEInfo.nCurrentIp & 0x0000ff00) >> 8);unsigned int nIp4 = (pstMVDevInfo->SpecialInfo.stGigEInfo.nCurrentIp & 0x000000ff);// en:Print current ip and user defined nameprintf("    IP: %d.%d.%d.%d\n" , nIp1, nIp2, nIp3, nIp4);printf("    UserDefinedName: %s\n" , pstMVDevInfo->SpecialInfo.stGigEInfo.chUserDefinedName);printf("    Device Model Name: %s\n\n", pstMVDevInfo->SpecialInfo.stGigEInfo.chModelName);}else if (MV_USB_DEVICE == pstMVDevInfo->nTLayerType){printf("    UserDefinedName: %s\n", pstMVDevInfo->SpecialInfo.stUsb3VInfo.chUserDefinedName);printf("    Device Model Name: %s\n\n", pstMVDevInfo->SpecialInfo.stUsb3VInfo.chModelName);}else{printf("    Not support.\n\n");}
}//  en:Convert pixel arrangement from RGB to BGR
void EDGE_CAMERA::RGB2BGR( unsigned char* pRgbData, unsigned int nWidth, unsigned int nHeight )
{if ( nullptr == pRgbData ){return;}// RGB TO BGRfor (unsigned int j = 0; j < nHeight; j++){for (unsigned int i = 0; i < nWidth; i++){unsigned char red = pRgbData[j * (nWidth * 3) + i * 3];pRgbData[j * (nWidth * 3) + i * 3]     = pRgbData[j * (nWidth * 3) + i * 3 + 2];pRgbData[j * (nWidth * 3) + i * 3 + 2] = red;}}
}// en:Convert data stream to Mat format then save image
bool EDGE_CAMERA::Convert2Mat(MV_FRAME_OUT_INFO_EX *pstImageInfo, unsigned char *pData, cv::Mat &img)
{if (nullptr == pstImageInfo || nullptr == pData){printf("NULL info or data.\n");return false;}cv::Mat srcImage;if ( PixelType_Gvsp_Mono8 == pstImageInfo->enPixelType )                // Mono8{srcImage = cv::Mat(pstImageInfo->nHeight, pstImageInfo->nWidth, CV_8UC1, pData);}else if ( PixelType_Gvsp_RGB8_Packed == pstImageInfo->enPixelType )     // RGB8{RGB2BGR(pData, pstImageInfo->nWidth, pstImageInfo->nHeight);srcImage = cv::Mat(pstImageInfo->nHeight, pstImageInfo->nWidth, CV_8UC3, pData);}else if(PixelType_Gvsp_BayerRG8 == pstImageInfo->enPixelType)           // BayerRG8{printf("pPixelType_Gvsp_BayerRG8 type is converted to Mat\n");//RGB2BGR(pData, pstImageInfo->nWidth, pstImageInfo->nHeight);srcImage = cv::Mat(pstImageInfo->nHeight, pstImageInfo->nWidth, CV_8UC1, pData);// srcImage.create(srcImage.rows,srcImage.cols,CV_8UC3);cvtColor(srcImage, srcImage, cv::COLOR_BayerRG2RGB);}else{printf("Unsupported pixel format\n");return false;}if ( nullptr == srcImage.data ){printf("Creat Mat failed.\n");return false;}try{// en:Save converted image in a local fileimg = srcImage;cv::imwrite("Image_Mat.bmp", srcImage);}catch (cv::Exception& ex){fprintf(stderr, "Exception in saving mat image: %s\n", ex.what());}srcImage.release();return true;
}// en:Convert data stream in Ipl format then save image
bool EDGE_CAMERA::Convert2Ipl(MV_FRAME_OUT_INFO_EX* pstImageInfo, unsigned char * pData)
{if (nullptr == pstImageInfo || nullptr == pData){printf("NULL info or data.\n");return false;}IplImage* srcImage = nullptr;if ( PixelType_Gvsp_Mono8 == pstImageInfo->enPixelType )                // Mono8????{srcImage = cvCreateImage(cvSize(pstImageInfo->nWidth, pstImageInfo->nHeight), IPL_DEPTH_8U, 1);}else if ( PixelType_Gvsp_RGB8_Packed == pstImageInfo->enPixelType )     // RGB8????{RGB2BGR(pData, pstImageInfo->nWidth, pstImageInfo->nHeight);srcImage = cvCreateImage(cvSize(pstImageInfo->nWidth, pstImageInfo->nHeight), IPL_DEPTH_8U, 3);}else{printf("Unsupported pixel format\n");return false;}if ( nullptr == srcImage ){printf("Creat IplImage failed.\n");return false;}srcImage->imageData = (char *)pData;try{// en:Save converted image in a local filecv::Mat cConvertImage = cv::cvarrToMat(srcImage);cv::imwrite("Image_Ipl.bmp", cConvertImage);cConvertImage.release();}catch (cv::Exception& ex){fprintf(stderr, "Exception in saving IplImage: %s\n", ex.what());}cvReleaseImage(&srcImage);return true;
}void EDGE_CAMERA::findCameras(){int nRet = MV_OK;//void* handle = nullptr;//unsigned char * pData = nullptr;//MV_CC_DEVICE_INFO_LIST _stDeviceList;memset(&_stDeviceList, 0, sizeof(MV_CC_DEVICE_INFO_LIST));// en:Enum devicedo {nRet = MV_CC_EnumDevices(MV_GIGE_DEVICE | MV_USB_DEVICE, &_stDeviceList);if (MV_OK != nRet) {printf("Enum Devices fail! nRet [0x%x]\n", nRet);break;}// en:Show devicesif (_stDeviceList.nDeviceNum > 0) {for (unsigned int i = 0; i < _stDeviceList.nDeviceNum; i++) {printf("[device %d]:\n", i);MV_CC_DEVICE_INFO *pDeviceInfo = _stDeviceList.pDeviceInfo[i];if (nullptr == pDeviceInfo) {break;}PrintDeviceInfo(pDeviceInfo);}} else {printf("Find No Devices!\n");break;}}while(false);
}void EDGE_CAMERA::connectCameras(){for(int device = 0; device < _stDeviceList.nDeviceNum; device++){if (!MV_CC_IsDeviceAccessible(_stDeviceList.pDeviceInfo[device], MV_ACCESS_Exclusive)){PrintDeviceInfo(_stDeviceList.pDeviceInfo[device]);printf("Can't connect %u! ", _stDeviceList.pDeviceInfo[device]->nMacAddrLow);continue;}else{void *handle;PrintDeviceInfo(_stDeviceList.pDeviceInfo[device]);printf("connect %10u!\n", _stDeviceList.pDeviceInfo[device]->nMacAddrLow);int nRet = MV_CC_CreateHandle(&handle, _stDeviceList.pDeviceInfo[device]);_handlesCameraInfos.push_back({handle,nRet}); //save the handle to handlesCameraInfosif (MV_OK != nRet){printf("Create Handle fail! nRet [0x%x]\n", nRet);}}}
}void EDGE_CAMERA::initCamera(void *handle, int createRetStatus, unsigned int cameraIndex) {int nRet;unsigned char * pData = nullptr;do{if (createRetStatus != MV_OK)break;handle = handle;// en:Open devicenRet = MV_CC_OpenDevice(handle);if (MV_OK != nRet) {printf("Open Device fail! nRet [0x%x]\n", nRet);break;}// en:Detection network optimal package size(It only works for the GigE camera)if (MV_GIGE_DEVICE == _stDeviceList.pDeviceInfo[cameraIndex]->nTLayerType) {int nPacketSize = MV_CC_GetOptimalPacketSize(handle);if (nPacketSize > 0) {nRet = MV_CC_SetIntValue(handle, "GevSCPSPacketSize", nPacketSize);if (MV_OK != nRet) {printf("Warning: Set Packet Size fail! nRet [0x%x]!", nRet);}} else {printf("Warning: Get Packet Size fail! nRet [0x%x]!", nPacketSize);}}//en:Set trigger mode as offnRet = MV_CC_SetEnumValue(handle, "TriggerMode", 0);if (MV_OK != nRet) {printf("Set Trigger Mode fail! nRet [0x%x]\n", nRet);break;}// en:Get payload sizeMVCC_INTVALUE stParam;memset(&stParam, 0, sizeof(MVCC_INTVALUE));nRet = MV_CC_GetIntValue(handle, "PayloadSize", &stParam);if (MV_OK != nRet) {printf("Get PayloadSize fail! nRet [0x%x]\n", nRet);break;}unsigned int nPayloadSize = stParam.nCurValue;// en:Init image infoMV_FRAME_OUT_INFO_EX stImageInfo = {0};memset(&stImageInfo, 0, sizeof(MV_FRAME_OUT_INFO_EX));pData = (unsigned char *) malloc(sizeof(unsigned char) * (nPayloadSize));if (nullptr == pData) {printf("Allocate memory failed.\n");break;}memset(pData, 0, sizeof(pData));//  en:Start grab imagenRet = MV_CC_StartGrabbing(handle);if (MV_OK != nRet) {printf("Start Grabbing fail! nRet [0x%x]\n", nRet);break;}_camerasDatas.push_back({handle,pData,nPayloadSize,stImageInfo});// en:Get one frame from camera with timeout=1000ms/*    while (true) {nRet = MV_CC_GetOneFrameTimeout(handle, pData, nPayloadSize, &stImageInfo, 1000);if (MV_OK == nRet) {printf("Get One Frame: Width[%d], Height[%d], FrameNum[%d]\n",stImageInfo.nWidth, stImageInfo.nHeight, stImageInfo.nFrameNum);} else {printf("Get Frame fail! nRet [0x%x]\n", nRet);break;}//  en:Convert image databool bConvertRet = false;cv::Mat img;bConvertRet = Convert2Mat(&stImageInfo, pData, img);cv::namedWindow("img", cv::WINDOW_NORMAL);cv::resizeWindow("img", cv::Size(900, 600));imshow("img", img);cv::waitKey(20);}*/}while(false);/* // en:Stop grab imagenRet = MV_CC_StopGrabbing(handle);if (MV_OK != nRet){printf("Stop Grabbing fail! nRet [0x%x]\n", nRet);break;}// en:Close devicenRet = MV_CC_CloseDevice(handle);if (MV_OK != nRet){printf("ClosDevice fail! nRet [0x%x]\n", nRet);break;}//  en:Input the format to convertprintf("\n[0] OpenCV_Mat\n");printf("[1] OpenCV_IplImage\n");int nFormat = 0;*/}void EDGE_CAMERA::initAllCameras(){unsigned int nCameraIndex = _handlesCameraInfos.size();unsigned int cameraIndex = 0;for(auto handlesCameraInfo:_handlesCameraInfos){initCamera(handlesCameraInfo.handle, handlesCameraInfo.createRetStatus, cameraIndex);cameraIndex++;}
}void EDGE_CAMERA::disPlay() {//initCamera(_handlesCameraInfos[0].handle, _handlesCameraInfos[0].createRetStatus, 0);std::string winName = "img";cv::namedWindow(winName, cv::WINDOW_NORMAL);cv::resizeWindow(winName, cv::Size(900, 600));while (cv::waitKey(50) != 'q') {unsigned int cameraIndex = 0;int nRet = MV_CC_GetOneFrameTimeout(_camerasDatas[0].handle, _camerasDatas[0].pData, _camerasDatas[0].nPayloadSize, &_camerasDatas[0].stImageInfo, 1000);if (MV_OK == nRet) {printf("Get One Frame: Width[%d], Height[%d], FrameNum[%d]\n",_camerasDatas[0].stImageInfo.nWidth, _camerasDatas[0].stImageInfo.nHeight, _camerasDatas[0].stImageInfo.nFrameNum);} else {printf("Get Frame fail! nRet [0x%x]\n", nRet);break;}//  en:Convert image databool bConvertRet = false;cv::Mat img;bConvertRet = Convert2Mat(&_camerasDatas[0].stImageInfo, _camerasDatas[0].pData, img);imshow(winName, img);cv::waitKey(20);}}bool EDGE_CAMERA::getAndProcessImg() {int nRet = MV_OK;void* handle = nullptr;unsigned char * pData = nullptr;do{MV_CC_DEVICE_INFO_LIST stDeviceList;memset(&stDeviceList, 0, sizeof(MV_CC_DEVICE_INFO_LIST));// en:Enum devicenRet = MV_CC_EnumDevices(MV_GIGE_DEVICE | MV_USB_DEVICE, &stDeviceList);if (MV_OK != nRet){printf("Enum Devices fail! nRet [0x%x]\n", nRet);break;}// en:Show devicesif (stDeviceList.nDeviceNum > 0){for (unsigned int i = 0; i < stDeviceList.nDeviceNum; i++){printf("[device %d]:\n", i);MV_CC_DEVICE_INFO* pDeviceInfo = stDeviceList.pDeviceInfo[i];if (nullptr == pDeviceInfo){break;}PrintDeviceInfo(pDeviceInfo);}}else{printf("Find No Devices!\n");break;}// en:Select deviceunsigned int nIndex = 0;while (true){printf("Please Input camera index(0-%d): ", stDeviceList.nDeviceNum - 1);if (1 == scanf("%d", &nIndex)){while (getchar() != '\n'){;}if (nIndex >= 0 && nIndex < stDeviceList.nDeviceNum){if (!MV_CC_IsDeviceAccessible(stDeviceList.pDeviceInfo[nIndex], MV_ACCESS_Exclusive)){printf("Can't connect! ");continue;}break;}}else{while (getchar() != '\n'){;}}}// en:Create handlenRet = MV_CC_CreateHandle(&handle, stDeviceList.pDeviceInfo[nIndex]);if (MV_OK != nRet){printf("Create Handle fail! nRet [0x%x]\n", nRet);break;}// en:Open devicenRet = MV_CC_OpenDevice(handle);if (MV_OK != nRet){printf("Open Device fail! nRet [0x%x]\n", nRet);break;}// en:Detection network optimal package size(It only works for the GigE camera)if (MV_GIGE_DEVICE == stDeviceList.pDeviceInfo[nIndex]->nTLayerType){int nPacketSize = MV_CC_GetOptimalPacketSize(handle);if (nPacketSize > 0){nRet = MV_CC_SetIntValue(handle, "GevSCPSPacketSize", nPacketSize);if (MV_OK != nRet){printf("Warning: Set Packet Size fail! nRet [0x%x]!", nRet);}}else{printf("Warning: Get Packet Size fail! nRet [0x%x]!", nPacketSize);}}//en:Set trigger mode as offnRet = MV_CC_SetEnumValue(handle, "TriggerMode", 0);if (MV_OK != nRet){printf("Set Trigger Mode fail! nRet [0x%x]\n", nRet);break;}// en:Get payload sizeMVCC_INTVALUE stParam;memset(&stParam, 0, sizeof(MVCC_INTVALUE));nRet = MV_CC_GetIntValue(handle, "PayloadSize", &stParam);if (MV_OK != nRet){printf("Get PayloadSize fail! nRet [0x%x]\n", nRet);break;}unsigned int nPayloadSize = stParam.nCurValue;// en:Init image infoMV_FRAME_OUT_INFO_EX stImageInfo = { 0 };memset(&stImageInfo, 0, sizeof(MV_FRAME_OUT_INFO_EX));pData = (unsigned char *)malloc(sizeof(unsigned char)* (nPayloadSize));if (nullptr == pData){printf("Allocate memory failed.\n");break;}memset(pData, 0, sizeof(pData));//  en:Start grab imagenRet = MV_CC_StartGrabbing(handle);if (MV_OK != nRet){printf("Start Grabbing fail! nRet [0x%x]\n", nRet);break;}// en:Get one frame from camera with timeout=1000msnRet = MV_CC_GetOneFrameTimeout(handle, pData, nPayloadSize, &stImageInfo, 1000);if (MV_OK == nRet){printf("Get One Frame: Width[%d], Height[%d], FrameNum[%d]\n",stImageInfo.nWidth, stImageInfo.nHeight, stImageInfo.nFrameNum);}else{printf("Get Frame fail! nRet [0x%x]\n", nRet);break;}// en:Stop grab imagenRet = MV_CC_StopGrabbing(handle);if (MV_OK != nRet){printf("Stop Grabbing fail! nRet [0x%x]\n", nRet);break;}// en:Close devicenRet = MV_CC_CloseDevice(handle);if (MV_OK != nRet){printf("ClosDevice fail! nRet [0x%x]\n", nRet);break;}//  en:Input the format to convertprintf("\n[0] OpenCV_Mat\n");printf("[1] OpenCV_IplImage\n");int nFormat = 0;while (1){printf("Please Input Format to convert: ");if (1 == scanf("%d", &nFormat)){if (0 == nFormat || 1 == nFormat){break;}}while (getchar() != '\n'){;}}//  en:Convert image databool bConvertRet = false;cv::Mat img;if (OpenCV_Mat == nFormat){bConvertRet = Convert2Mat(&stImageInfo, pData, img);}else if (OpenCV_IplImage == nFormat){bConvertRet = Convert2Ipl(&stImageInfo, pData);}//  en:Print resultif (bConvertRet){printf("OpenCV format convert finished.\n");}else{printf("OpenCV format convert failed.\n");}} while (0);// en:Destroy handleif (handle){MV_CC_DestroyHandle(handle);handle = nullptr;}// en:Free memeryif (pData){free(pData);pData = nullptr;}return true;
}void EDGE_CAMERA::saveImg(std::string path,unsigned int cameraIndex){}

Main函数

int main(int argc, char **argv){EDGE_CAMERA camera;camera.findCameras();camera.connectCameras();camera.initAllCameras();camera.disPlay();}

执行效果

在这里插入图片描述

注意

我是编译了一个动态库cameraAPI,main函数是链接的camkeraAPI。上面是把最重要的代码给贴出来了。不是完整的工程哈。

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

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

相关文章

火绒能一键修复所有dll缺失吗?教你快速修复dll文件

关于dll文件的缺少&#xff0c;其实大家应该都是不陌生的吧&#xff0c;毕竟只要是经常使用电脑的人&#xff0c;那么它就一定碰到过各种各样的dll文件缺失&#xff0c;因为很多程序都是需要dll文件来支撑的&#xff0c;如果dll文件丢失了&#xff0c;那么一些程序就会启动不了…

Python基础学习第三天:Python语法

执行 Python 语法 正如我们在上一节中学习到的&#xff0c;可以直接在命令行中编写执行 Python 的语法&#xff1a; >>> print("Hello, World!") Hello, World!或者通过在服务器上创建 python 文件&#xff0c;使用 .py 文件扩展名&#xff0c;并在命令行…

5 种 可帮助开发人员提高工作效率的AI 工具

推荐&#xff1a;使用 NSDT场景编辑器 助你快速搭建3D应用场景 如果没有完整的团队&#xff0c;学习新功能或修复旧问题可能会占用不成比例的时间——可能是数小时的搜索、阅读文档和观看教学视频。幸运的是&#xff0c;人工智能的进步大大加快了这一过程。 每个人都立即想到的…

【内推码:NTAMW6c】 MAXIEYE智驾科技2024校招启动啦

MAXIEYE智驾科技2024校招启动啦【内推码&#xff1a;NTAMW6c】 【招聘岗位超多&#xff01;&#xff01;公司食堂好吃&#xff01;&#xff01;】 算法类&#xff1a;感知算法工程师、SLAM算法工程师、规划控制算法工程师、目标及控制算法工程师、后处理算法工程师 软件类&a…

SpringCloud入门——微服务调用的方式 RestTemplate的使用 使用nacos的服务名初步(Ribbon负载均衡)

目录 引出微服务之间的调用几种调用方法spring提供的组件 RestTemplate的使用导入依赖生产者模块单个配置的情况多个配置的情况没加.yaml的报错【报错】两个同名配置【细节】 完整代码config配置主启动类controller层 消费者模块进行配置restTemplate配置类controller层 使用na…

13.redis集群、主从复制、哨兵

1.redis主从复制 主从复制是指将一台redis服务器&#xff08;主节点-master&#xff09;的数据复制到其他的redis服务器&#xff08;从节点-slave&#xff09;&#xff0c;默认每台redis服务器都是主节点&#xff0c;每个主节点可以有多个或没有从节点&#xff0c;但一个从节点…

Flink Kubernates Native - 入门

创建 namespace [rootCentOSA flink-1.17.1]# kubectl create ns flink-native [rootCentOSA flink-1.17.1]# kubectl config set-context --current --namespaceflink-native命令空间添加资源限制 [rootCentOSA flink-1.17.1]# vim namespace-ResourceQuota.yamlapiVersion:…

Maven报错 [ERROR] Malformed \uxxxx encoding.

IDEA刷新项目&#xff0c;报错[ERROR] Malformed \uxxxx encoding. 现象 1.控制台报错 [ERROR] Malformed \uxxxx encoding.2.项目代码大部分爆红 3.Pom文件不爆红 4.IDEA未能构建Dependencies 尝试清除IDEA缓存无效&#xff0c;重新克隆项目无效&#xff0c;更换低版本mav…

精进面试技巧:如何在程序员面试中脱颖而出

&#x1f337;&#x1f341; 博主猫头虎 带您 Go to New World.✨&#x1f341; &#x1f984; 博客首页——猫头虎的博客&#x1f390; &#x1f433;《面试题大全专栏》 文章图文并茂&#x1f995;生动形象&#x1f996;简单易学&#xff01;欢迎大家来踩踩~&#x1f33a; &a…

DPI 设置和获取

DPI设置与获取之前请保证程序已经打开DPI感知或者在清单文件嵌入DPI感知&#xff0c;否则API可能获取的值不准确 方法一:GetScaleFactorForMonitor 通过枚举显示器获取不同设备的DPI&#xff0c;获取的是实际DPI static BOOL CALLBACK MonitorEnumProc(HMONITOR hMonitor,HDC…

服务器数据恢复-ESXi虚拟化误删除的数据恢复案例

服务器数据恢复环境&#xff1a; 一台服务器安装的ESXi虚拟化系统&#xff0c;该虚拟化系统连接了多个LUN&#xff0c;其中一个LUN上运行了数台虚拟机&#xff0c;虚拟机安装Windows Server操作系统。 服务器故障&分析&#xff1a; 管理员因误操作删除了一台虚拟机&#x…

报错处理:Permission denied错误

报错处理 Permission denied错误 报错环境 在Linux上运行任何需要访问系统资源、文件或目录的命令时均有可能出现。 排错思路 该错误表示当前用户没有足够的权限执行指定的操作。排查时可以先查看具体的报错信息&#xff0c;例如文件或目录的路径以及相应的权限设置&#xff0c…

字符设备驱动(内核态用户态内存交互)

前言 内核驱动&#xff1a;运行在内核态的动态模块&#xff0c;遵循内核模块框架接口&#xff0c;更倾向于插件。 应用程序&#xff1a;运行在用户态的进程。 应用程序与内核驱动交互通过既定接口&#xff0c;内核态和用户态访问依然遵循内核既定接口。 环境搭建 系统&#…

HHDESK一键改密功能

HHDESK新增实用功能——使用SSH连接&#xff0c;对服务器/端口进行密码修改。 1 测试 首页点击资源管理——客户端&#xff0c;选择需要修改的连接&#xff1b; 可以先对服务器及端口进行测试&#xff0c;看是否畅通&#xff1b; 右键——测试——ping&#xff1b; 以及右…

【Python数据分析】Matplotlib小技巧!

1. 添加标题-title matplotlib.pyplot 对象中有个 title() 可以设置表格的标题。 **import** numpy **as** np **import** matplotlib.pyplot **as** plt \# 显示中文 plt.rcParams\[font.sans-serif\] \[uSimHei\] plt.rcParams\[axes.unicode\_minus\] **False** …

Spark整合hive的时候出错

Spark整合hive的时候 连接Hdfs不从我hive所在的机器上找&#xff0c;而是去连接我的集群里的另外两台机器 但是我的集群没有开 所以下面就一直在retry 猜测&#xff1a; 出现这个错误的原因可能与core-site.xml和hdfs-site.xml有关&#xff0c;因为这里面配置了集群的nameno…

三---开关稳压器

通过控制系统反馈&#xff0c;当电压上升时通过反馈降低&#xff0c;当电压下降时通过反馈升高&#xff1b;形成一个控制环路&#xff1b;控制电路&#xff1a;PWM&#xff08;脉宽调制&#xff09;&#xff0c;PFM&#xff08;频率控制方式&#xff09;&#xff0c;移相控制方…

Java并发编程第6讲——线程池(万字详解)

Java中的线程池是运用场景最多的并发框架&#xff0c;几乎所有需要异步或并发执行任务的程序都可以使用线程池&#xff0c;本篇文章就详细介绍一下。 一、什么是线程池 定义&#xff1a;线程池是一种用于管理和重用线程的技术&#xff08;池化技术&#xff09;&#xff0c;它主…

AcWing 898. 数字三角形 (每日一题)

大家好 我是寸铁 希望这篇题解对你有用&#xff0c;麻烦动动手指点个赞或关注&#xff0c;感谢您的关注 注意 像数组下标出现i-1的&#xff0c;在循环的时候从i1开始。 关于0x3f3f3f3f和Integer.MAX_VALUE 0x3f3f3f3f:1061109567 Integer.MAX_VALUE:2147483647 在选用Integ…

【缓存设计】记一种不错的缓存设计思路

文章目录 前言场景设计思路小结 前言 之前与同事讨论接口性能问题时听他介绍了一种缓存设计思路&#xff0c;觉得不错&#xff0c;做个记录供以后参考。 场景 假设有个以下格式的接口&#xff1a; GET /api?keys{key1,key2,key3,...}&types{1,2,3,...}其中 keys 是业务…