未定义标识符:“SiftFeatureDetector” 解决办法

版权声明:本文为博主原创文章,遵循 CC 4.0 by-sa 版权协议,转载请附上原文出处链接和本声明。
本文链接:https://blog.csdn.net/bz_xyz/article/details/88016453

环境:
visual studio 2017
opencv4.0.1

  1. 首先,sift不在opencv默认下载的库里面,需要自己额外配置,具体方法见以下链接:
    OpenCV3.0丢失Nonfree模块——Simon_Lanzhou
    写的很好,一步一步跟着做,这个版本是适用的;
  2. 配置完成后,即便加入了nonfree.hpp这个头文件,依旧遇到题目所说的问题:未定义标识符:“SiftFeatureDetector”,只需补充这一句话即可:
using namespace cv::xfeatures2d
展开阅读全文

全局变量出现未定义标识符

05-22

用试验hook时发现一个已经定义了全局变量的变量,在dllmain.cpp中显示未定义标示符rn求大神解惑rnrndllmain.app中的代码rn[code=c]rnrn// dllmain.cpp : 定义 DLL 的初始化例程。rn//rnrn#include "stdafx.h"rn#include rn#include rnrn#ifdef _DEBUGrn#define new DEBUG_NEWrn#endifrnrnrnstatic AFX_EXTENSION_MODULE ActivityKeyDLL = NULL, NULL ;rnrnextern "C" int APIENTRY DllMain(HINSTANCE hInstance, DWORD dwReason, LPVOID lpReserved)rnrn//如果使用lpReserved参数则删除下面这行rn UNREFERENCED_PARAMETER(lpReserved);rn if (dwReason == DLL_PROCESS_ATTACH)rn rn TRACE0("NOtePadHOOK.DLL Initializing!\n");rn //扩展DLL仅初始化一次rn if (!AfxInitExtensionModule(ActivityKeyDLL, hInstance))rn return 0;rn new CDynLinkLibrary(ActivityKeyDLL);rn //把DLL加入动态MFC类库中rn glhInstance=hInstance;//出错点提示glhInstance未定义标识符rn //插入保存DLL实例句柄rn rn else if (dwReason == DLL_PROCESS_DETACH)rn rn TRACE0("NotePadHOOK.DLL Terminating!\n");rn //终止这个链接库前调用它rn AfxTermExtensionModule(ActivityKeyDLL);rn rn return 1;rn[/code]rnrnrn主文件中的代码rn[code=c]rn// ActivityKey.cpp : 定义 DLL 的初始化例程。rn//rnrn#include "stdafx.h"rn#include "ActivityKey.h"rnrnrnrn#ifdef _DEBUGrn#define new DEBUG_NEWrn#endifrnrn//shared data section全局共享数据rn#pragma data_seg("sharedata")rnHHOOK glhHook=NULL; //钩子句柄。rnHINSTANCE glhInstance=NULL; //dll实例句柄。(此处申明了glhInstance变量)rn#pragma data_seg()rnrnrnextern "C" LRESULT WINAPI KeyboardProc(int nCode,WPARAM wParam,LPARAM lParam)rnrn if( nCode >= 0 )rn rn if( wParam == 0X79 )//当按下F10键时,激活外挂。rn rn //外挂实现代码。rn CPoint newPoint,oldPoint;rn GetCursorPos(&oldPoint);rn newPoint.x = oldPoint.x+40;rn newPoint.y = oldPoint.y+10;rn SetCursorPos(newPoint.x,newPoint.y);rn mouse_event(MOUSEEVENTF_LEFTDOWN,0,0,0,0);//模拟按下鼠标左键。rn mouse_event(MOUSEEVENTF_LEFTUP,0,0,0,0);//模拟放开鼠标左键。rn keybd_event(VK_SHIFT,MapVirtualKey(VK_SHIFT,0),0,0); //按下SHIFT键。rn keybd_event(0x52,MapVirtualKey(0x52,0),0,0);//按下R键。rn keybd_event(0x52,MapVirtualKey(0x52,0),KEYEVENTF_KEYUP,0);//放开R键。rn keybd_event(VK_SHIFT,MapVirtualKey(VK_SHIFT,0),KEYEVENTF_KEYUP,0);//放开SHIFT键。rn SetCursorPos(oldPoint.x,oldPoint.y);rn rn rn return CallNextHookEx(glhHook,nCode,wParam,lParam);rnrnrnCKeyHook::CKeyHook()rnrnrnrnrnCKeyHook::~CKeyHook()rnrn Stop();rnrnrn //install static hookrnBOOL CKeyHook::Start()rnrn BOOL bResult=FALSE;rn glhHook = SetWindowsHookEx(WH_KEYBOARD,KeyboardProc,glhInstance,0);//设置键盘钩子。rn if(glhHook!=NULL)rn bResult=TRUE;rn return bResult;rnrn //卸载全局钩子。rnBOOL CKeyHook::Stop()rnrn BOOL bResult = TRUE;rn if( glhHook )rn bResult = UnhookWindowsHookEx(glhHook);//卸载键盘钩子。rn return bResult;rnrn[/code] 论坛

没有更多推荐了,返回首页