我试图在运行Ubuntu 14.04.2的计算机上安装带有额外模块的OpenCV(我需要这个特定版本的Ubuntu,因为我正在使用其他需要它的硬件)。我上周刚刚在Raspberry Pi 3上运行它(运行Ubuntu Mate 16.04.3),但现在我似乎无法做到这一点。
我知道opencv_contrib-version需要与opencv-version相同,我尝试过很多不同的版本(3.4.0,3.3.0,3.2.0,3.1.0) )。
下载了opencv和opencv_contrib的匹配版本后,我从终端执行以下命令:
$ cd opencv
$ mkdir build
$ cd build
$ cmake -D OPENCV_EXTRA_MODULES_PATH = ../../opencv_contrib/modules ..
其中opencv和opencv_contrib文件夹都位于桌面上,因此" ../../ opencv_contrib / modules" -path应该是正确的。
但是额外的模块还没有建成。以下是cmake输出的部分内容:
- OpenCV模块:
- 即将建成:core flann imgproc ml objdetect photo video dnn imgcodecs shape videoio highgui superres ts features2d calib3d拼接视频标签
- 已禁用:世界
- 依赖性禁用: -
- 不可用:cudaarithm cudabgsegm cudacodec cudafeatures2d cudafilters cudaimgproc cudalegacy cudaobjdetect cudaoptflow cudastereo cudawarping cudev java python2 python3 viz
正如您所看到的,它只是包含的标准模块。我见过很多人遇到同样的问题,但解决方案一直是关于拥有匹配的opencv / opencv_contrib版本。现在我知道版本是正确的,我不知道我做错了什么。
答案 0 :(得分:1)
namespace MyApp.Service.WebAPI
{
/// <summary>
/// http://autofac.readthedocs.io/en/latest/register/scanning.html#scanning-for-modules
/// </summary>
public class AutofacModule : Autofac.Module
{
protected override void Load(ContainerBuilder builder)
{
// MyApp.Application.Core
builder.RegisterAssemblyTypes(typeof(IService).GetTypeInfo().Assembly).AsImplementedInterfaces();
// MyApp.Application
builder.RegisterAssemblyTypes(typeof(ISampleService).GetTypeInfo().Assembly).AsImplementedInterfaces();
// MyApp.Domain.Core
builder.RegisterAssemblyTypes(typeof(IResolver).GetTypeInfo().Assembly).AsImplementedInterfaces();
// MyApp.Domain
builder.RegisterAssemblyTypes(typeof(ISampleRepository).GetTypeInfo().Assembly).AsImplementedInterfaces();
//builder.RegisterAssemblyTypes(typeof(SampleApplyCommand).GetTypeInfo().Assembly).AsImplementedInterfaces();
// MyApp.Infrastructure.Data
builder.RegisterAssemblyTypes(typeof(IDbFactory).GetTypeInfo().Assembly).AsImplementedInterfaces();
}
}
}
namespace MyApp.Service.WebAPI
{
public static class WebApiConfig
{
public static void Register(HttpConfiguration config)
{
// Web API configuration and services
var builder = new ContainerBuilder();
builder.RegisterApiControllers(Assembly.GetExecutingAssembly());
builder.RegisterModule(new AutofacModule());
var container = builder.Build();
config.DependencyResolver = new AutofacWebApiDependencyResolver(container);
// Web API routes
config.MapHttpAttributeRoutes();
config.Routes.MapHttpRoute(
name: "DefaultApi",
routeTemplate: "api/{controller}/{id}",
defaults: new { id = RouteParameter.Optional }
);
}
}
}
namespace MyApp.Domain
{
public class SampleCommandHandler : ICommandHandler<SampleCommand>
{
private readonly ISampleRepository _sampleRepository;
private readonly IValidator<SampleCommand> _sampleCommandValidator;
public SampleCommandHandler(ISampleRepository sampleRepository, IValidator<SampleCommand> sampleCommandValidator)
{
_sampleRepository = sampleRepository;
_sampleCommandValidator = sampleCommandValidator;
}
public IEnumerable<IEvent> Handle(SampleCommand command)
{
var validate = _sampleCommandValidator.Validate(command);
if (!validate.IsValid)
{
throw new DomainException(validate.Errors.Select(s => s.ErrorMessage));
}
var sample = _sampleRepository.Read(command.SampleNumber);
sample.Apply(command);
_sampleRepository.Update(sample);
return sample.Events;
}
}
}
namespace MyApp.Domain
{
public class SampleCommand : ICommand
{
public SampleCommand()
{
}
public SampleCommand(string sampleNumber)
{
SampleNumber = sampleNumber;
}
public string SampleNumber { get; set; }
}
}
namespace MyApp.Domain
{
public class SampleValidator<T> : AbstractValidator<T> where T : SampleCommand
{
private readonly ISampleRules _sampleRules;
public SampleValidator(ISampleRules sampleRules)
{
_sampleRules = sampleRules;
RuleFor(rule => rule.SampleNumber)
.NotEmpty().WithMessage(DomainValidationMessages.SampleNumberCannotBeEmpty);
}
}
}
namespace MyApp.Domain.Core
{
public interface IResolver
{
T Resolve<T>();
IEnumerable<T> ResolveAll<T>();
}
}
namespace MyApp.Domain.Core
{
public class AutofacResolver : IResolver
{
private readonly IComponentContext _context;
public AutofacResolver(IComponentContext context)
{
_context = context;
}
public T Resolve<T>()
{
return _context.Resolve<T>();
}
public IEnumerable<T> ResolveAll<T>()
{
return _context.Resolve<IEnumerable<T>>().ToList();
}
}
}
调用中=
周围有多余的空格,因此路径设置不正确。删除这两个空格你应该没问题:
cmake