-
Notifications
You must be signed in to change notification settings - Fork 13
Expand file tree
/
Copy pathDistanceTransformTOP.h
More file actions
90 lines (74 loc) · 2.78 KB
/
DistanceTransformTOP.h
File metadata and controls
90 lines (74 loc) · 2.78 KB
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
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
/* Shared Use License: This file is owned by Derivative Inc. (Derivative)
* and can only be used, and/or modified for use, in conjunction with
* Derivative's TouchDesigner software, and only if you are a licensee who has
* accepted Derivative's TouchDesigner license or assignment agreement
* (which also govern the use of this file). You may share or redistribute
* a modified version of this file provided the following conditions are met:
*
* 1. The shared file or redistribution must retain the information set out
* above and this list of conditions.
* 2. Derivative's name (Derivative Inc.) or its trademarks may not be used
* to endorse or promote products derived from this file without specific
* prior written permission from Derivative.
*/
#ifndef __DistanceTransformTOP__
#define __DistanceTransformTOP__
#include "TOP_CPlusPlusBase.h"
#include "Parameters.h"
#include <opencv2/core.hpp>
#include <opencv2/imgproc.hpp>
#include <string>
/*
This example implements a TOP to calculate the distance transform using OpenCV.
It takes the following parameters:
- Distance Type: One of [L1, L2, C], which determines how to calculate the distance.
- Mask Size: One of [3x3, 5x5, Precise], which determines the size of the transform mask.
- Normalize: If On, normalize the output image.
For more information visit: https://docs.opencv.org/3.4/d7/d1b/group__imgproc__misc.html#ga8a0b7fdfcb7a13dde018988ba3a43042
This TOP takes one input which must be 8 bit single channel.
*/
// To get more help about these functions, look at TOP_CPlusPlusBase.h
class DistanceTransformTOP : public TD::TOP_CPlusPlusBase
{
public:
DistanceTransformTOP(const TD::OP_NodeInfo *info, TD::TOP_Context *context);
virtual ~DistanceTransformTOP();
virtual void getGeneralInfo(TD::TOP_GeneralInfo*, const TD::OP_Inputs*, void* reserved) override;
virtual void execute(TD::TOP_Output*, const TD::OP_Inputs*, void* reserved) override;
virtual void setupParameters(TD::OP_ParameterManager*, void* reserved) override;
private:
void inputTopToMat(const TD::OP_Inputs*);
void cvMatToOutput(TD::TOP_Output*, TD::TOP_UploadInfo) const;
int getType(DistancetypeMenuItems dt)
{
switch (dt)
{
default:
case DistancetypeMenuItems::L1:
return cv::DIST_L1;
case DistancetypeMenuItems::L2:
return cv::DIST_L2;
case DistancetypeMenuItems::C:
return cv::DIST_C;
}
}
int getMask(MasksizeMenuItems ms)
{
switch (ms)
{
default:
case MasksizeMenuItems::Three:
return cv::DIST_MASK_3;
case MasksizeMenuItems::Five:
return cv::DIST_MASK_5;
case MasksizeMenuItems::Precise:
return cv::DIST_MASK_PRECISE;
}
}
cv::Mat* myFrame;
int myExecuteCount;
TD::TOP_Context* myContext;
TD::OP_SmartRef<TD::OP_TOPDownloadResult> myPrevDownRes;
Parameters myParms;
};
#endif