vc服务程序带有opencv相关代码就启动不了。

wuxiao0313 2018-07-24 08:49:49
windows10下,vc编写的服务程序,只要程序中包含opencv相关的代码服务就不能启动,将其全部注释掉就可正常启动。 有遇到类似情况的吗?
...全文
257 6 打赏 收藏 转发到动态 举报
写回复
用AI写文章
6 条回复
切换为时间正序
请发表友善的回复…
发表回复
shiter 2018-08-05
  • 打赏
  • 举报
回复
这种问题一定是没配置正确
jacksonfan 2018-08-04
  • 打赏
  • 举报
回复
怀疑是dll相关库路径的问题
tiger波波 2018-08-03
  • 打赏
  • 举报
回复
库文件路径之类的对吗?是不是缺库文件
oyljerry 2018-07-24
  • 打赏
  • 举报
回复
可能是opencv有用到用户session的东西,而服务session没有桌面等
赵4老师 2018-07-24
  • 打赏
  • 举报
回复
用调试器(OD,WINDBG等)调试服务程序
To debug the initialization code of a service application, the debugger must be attached when the service is started. This is accomplished by creating a registry key:

HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Image File Execution Options\ProgramName


The ProgramName is the image file for the service application you are debugging. Do not specify a path. For example, the ProgramName might look like MyService.exe.

Under this key create a string data value called Debugger. The value of this string should be set to the full path of the debugger that will be used. For example,

c:\Debuggers\windbg.exe



In addition to setting this registry key, the service application must be marked as "interactive". This allows your service to interact with the desktop, and allows the debugger window to appear on your desktop.

This again requires modifying a registry key: you must bitwise-or the type entry for your service with 0x100 (this is the value for SERVICE_INTERACTIVE_PROCESS according to Winnt.h). The exact location and name of this registry entry varies. For example:

HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\MyServiceKey


Finally, you need to adjust the service application timeout. Otherwise, the service application will kill the debugger within 20 seconds after starting. Adjusting the timeout involves setting an entry in the following registry key:

HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control


Under this key, create a DWORD data value called ServicesPipeTimeout. Set this entry to the amount of time in milliseconds that you want the service to wait before timing out. For example, 60,000 is one minute, while 86,400,000 is 24 hours.

设置ServicesPipeTimeout后需要重启系统才生效

Now, when the service is started, the debugger will also start. When the debugger starts, it will stop at the initial process breakpoint, before the service has begun running. This allows you to set breakpoints or otherwise configure your debugging session to let you monitor the startup of your service. Another option is to place calls to the DebugBreak function in your service from the point at which you would like to break into the debugger. (For more information, see DebugBreak in the Platform SDK documentation.)

If your service is running with other services in a Service Host Process, you may need to isolate the service into its own Service Host Process.
wuxiao0313 2018-07-24
  • 打赏
  • 举报
回复
引用 1 楼 oyljerry的回复:
可能是opencv有用到用户session的东西,而服务session没有桌面等
服务设置了与桌面交互,但你说这个我想到了系统权限和令牌的一些问题,我加进去试试
    本课程分享对由中国开发者提供的OpenCV条形码识别模块的原理和代码精讲。该模块借鉴“目标识别”领域先进理念,采用“定位-识别”二段模式,有效提高了自然环境下条码识别的准确率并保持了C++代码的高速度,相比较常用的zxing和zbar在准确率和识别速度上均有较大优势。更难得可贵的是在代码的实现过程中能够注意细节,在诸如“循环测试确定参数数值”“积分图的使用”“倾斜矩形纠偏”等处,均提供了思路清晰、弹性高的优质代码。作为一套通过了OpenCV官方的代码检验、解决一个常用领域内具体问题的模块,对于图像处理学习来说是难得可贵的。    逐条进行代码解读繁琐且低效,个人认为,在图像处理领域,能够运行和修改观察的代码对于学习研究至关重要。在理论剖析部分,也是由应用引导原理。同时做好知识的迁移和代码的复用工作。在这个过程中,创建针对性的实验非常重要。 课程内容分为4个部分:一是基本配置,包括· 条形码识别模块的安装使用 (cmake配置和OpenCV编译);· 构建用于测试和代码阅读的环境;· 模块对官方数据集的测试;二是条码定位,将详细讲解思路、原理和实现知识迁移部分将简单说一下在毛发识别上的迁移:三是条码识别,该部分内容会首先梳理框架,而后具体进行分析讲解    此外,我们将结合例子,将OpenCV的基础功能,包括积分图像、形态学变化、联通区域、透视变化等进行复习,加深理解。 

19,468

社区成员

发帖
与我相关
我的任务
社区描述
VC/MFC 图形处理/算法
社区管理员
  • 图形处理/算法社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧