alvin.chen
2019-11-29 edf127edc771f715c49f86e91e768633f0a0ed93
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using HalconDotNet;
 
namespace HalconTools
{
    public class JobAssistance
    {
        public JobAssistance()
        {
        }
 
        /// <summary>
        /// 单独工具运行
        /// </summary>
        /// <param name="tool"></param>
        public JobResult ToolRun(HImage image,JobTool tool)
        {
            JobResult tmpResult = new JobResult();
            FitAssistant mfit = new FitAssistant();
            MatchingAssistant mMatch = new MatchingAssistant();
            ScrewAssistant mScrew = new ScrewAssistant();
 
            switch (tool.type)
            {
                case ToolType.FindCircle:
 
                    tmpResult.fitCircleResult = new FitCircleResult();
                    mfit.mImage = image;
                    tmpResult.fitCircleResult = mfit.FitCircle(tool.fitCircleParam);
 
                    break;
 
                case ToolType.FindLine:
 
                    tmpResult.fitLineResult = new FitLineResult();
                    mfit.mImage = image;
                    tmpResult.fitLineResult = mfit.FitLine(tool.fitLineParam);
 
                    break;
 
                case ToolType.Matching:
 
                    tmpResult.matchingResult = new MatchingResult();
                    mMatch.mImage = image;
                    mMatch.parameterSet = tool.matchingParam;
 
                    mMatch.loadShapeModel(tool.modelPath);
                    mMatch.detectShapeModel();
 
                    tmpResult.matchingResult = mMatch.tResult;
 
                    break;
 
                case ToolType.Screw:
 
                    tmpResult.screwResult = new ScrewResult();
                    mScrew.mImage = image;
                    mScrew.SetPara(tool.screwParam);
                    mScrew.Run();
                    tmpResult.screwResult = mScrew.mScrewResult;
 
                    break;
            }
 
            return tmpResult;
        }
 
    }
}