本文整理汇总了Python中harpia.model.plugin.Plugin类的典型用法代码示例。如果您正苦于以下问题:Python Plugin类的具体用法?Python Plugin怎么用?Python Plugin使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Plugin类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
def __init__(self):
Plugin.__init__(self)
# Appearance
self.help = "Checks Wheather the given " + \
"point is inside the given rectangle."
self.label = "Check Point"
self.color = "50:50:200:150"
self.in_types = ["harpia.extensions.c.ports.point", "harpia.extensions.c.ports.rect"]
self.out_types = ["harpia.extensions.c.ports.double"]
self.group = "Experimental"
# ------------------------------C/OpenCv code--------------------------
self.codes[2] = \
'\n block$id$_double_o0 = 0.0;\n' + \
'if(block$id$_point_i0.x >= block$id$_rect_i1.x)\n' + \
' if(block$id$_point_i0.y >= block$id$_rect_i1.y)\n' + \
' if(block$id$_point_i0.x < block$id$_rect_i1.x + ' + \
'block$id$_rect_i1.width)\n' + \
' if(block$id$_point_i0.y < block$id$_rect_i1.y + ' + \
'block$id$_rect_i1.height)\n' + \
' block$id$_double_o0 = 1.0;\n'
self.language = "c"
self.framework = "opencv"
示例2: __init__
def __init__(self):
Plugin.__init__(self)
# Appearance
self.help = "Creates new literal value (Int)."
self.label = "New Int"
self.color = "50:50:200:150"
self.out_types = [{"type":"harpia.extensions.c.ports.int",
"name":"value",
"label":"Value"}]
self.group = "Basic Data Type"
self.properties = [{"name": "Value",
"label": "intVal",
"type": HARPIA_INT,
"lower": 0,
"upper": 65535,
"step": 1,
"value":1
}
]
# -------------------C/OpenCv code------------------------------------
self.codes[1] = 'int block$id$_int_o0 = $intVal$; // New Int Out\n'
self.language = "c"
self.framework = "opencv"
示例3: __init__
def __init__(self):
Plugin.__init__(self)
# Appearance
self.help = "Realiza a negação lógica de uma imagem. " + \
"Corresponde à negativa da imagem."
self.label = "Not"
self.color = "10:180:10:150"
self.in_ports = [{"type":"harpia.extensions.c.ports.image",
"name":"input_image",
"label":"Input Image"}
]
self.out_ports = [{"type":"harpia.extensions.c.ports.image",
"name":"output_image",
"label":"Output Image"}]
self.group = "Arithmetic and logical operations"
self.codes[1] = "IplImage * block$id$_img_i0 = NULL;\n" + \
"IplImage * block$id$_img_o0 = NULL;\n"
self.codes[2] = \
'if(block$id$_img_i0){\n' + \
'block$id$_img_o0 = cvCloneImage(block$id$_img_i0);\n' + \
'cvNot(block$id$_img_i0, block$id$_img_o0);\n' + \
'}\n'
self.codes[3] = "cvReleaseImage(&block$id$_img_i0);\n" + \
"cvReleaseImage(&block$id$_img_o0);\n"
self.language = "c"
self.framework = "opencv"
示例4: __init__
def __init__(self):
Plugin.__init__(self)
self.language = "javascript"
self.framework = "webaudio"
self.help = "Mouse Position"
self.label = "Mouse Position"
self.color = "50:50:50:150"
self.out_types = ["harpia.extensions.javascript.ports.float", "harpia.extensions.javascript.ports.float"]
self.out_ports = [
{"type":"harpia.extensions.javascript.ports.float",
"name":"x",
"label":"X"},
{"type":"harpia.extensions.javascript.ports.float",
"name":"y",
"label":"Y"}
]
self.group = "Interface"
self.codes[1] = """
// block_$id$ = Mouse
var $out_ports[x]$ = [];
var $out_ports[y]$ = [];
"""
self.codes[0] = """
示例5: __init__
def __init__(self):
Plugin.__init__(self)
self.frameNumber = 5
# Appearance
self.help = "Inserts a delay inside a live stream."
self.label = "Live Delay"
self.color = "250:20:30:150"
self.in_types = ["harpia.extensions.c.ports.image"]
self.out_types = ["harpia.extensions.c.ports.image"]
self.group = "General"
self.properties = [{"name": "Time (in frames)",
"label": "frameNumber",
"type": HARPIA_INT,
"lower": 1,
"upper": 200,
"step": 1
}
]
# ------------------------------C/OpenCv code--------------------------
self.codes[2] = '''
if(block$id$_img_i0){
cvReleaseImage(&(block$id$_buffer[i_$id$]));
block$id$_buffer[i_$id$] = cvCloneImage(block$id$_img_i0);
i_$id$++;
i_$id$ %= $frameNumber$;
block$id$_img_o0 = block$id$_buffer[i_$id$];
}
'''
self.codes[3] = 'cvReleaseImage(&block$id$_img_i0);\n'
self.codes[4] = '''
示例6: __init__
def __init__(self):
Plugin.__init__(self)
self.language = "javascript"
self.framework = "webaudio"
self.help = "Print value"
self.label = "Print"
self.color = "50:150:250:150"
self.in_ports = [{"type":"harpia.extensions.javascript.ports.float",
"name":"float_value",
"label":"Float Value"},
{"type":"harpia.extensions.javascript.ports.char",
"name":"Char Value",
"label":"char_value"}
]
self.group = "Interface"
self.properties = [{"name": "label",
"label": "Label",
"value": "Label",
"type": HARPIA_STRING
}
]
self.codes[1] = """
// block_$id$ = $name$
var $in_ports[float_value]$ = function(value){
document.getElementById("block_$id$").innerHTML = value;
return true;
};
var $in_ports[char_value]$ = $in_ports[result]$;
"""
self.codes[3] = """
示例7: __init__
def __init__(self):
Plugin.__init__(self)
self.doubleVal = 1
# Appearance
self.help = "Creates new literal value (Double)."
self.label = "New Double"
self.color = "50:50:200:150"
self.out_types = ["harpia.extensions.c.ports.double"]
self.group = "Basic Data Type"
self.properties = [{"name": "Value",
"label": "doubleVal",
"type": HARPIA_FLOAT,
"lower": 0,
"upper": 65535,
"step": 1
}
]
# -------------------C/OpenCv code------------------------------------
self.codes[1] = 'double block$id$_double_o0 = ' + \
'$doubleVal$; // New Double Out\n'
self.language = "c"
self.framework = "opencv"
示例8: __init__
def __init__(self):
Plugin.__init__(self)
self.width = "640"
self.height = "480"
# Appearance
self.help = "Cria uma nova imagem."
self.label = "New Image"
self.color = "50:100:200:150"
self.out_types = ["harpia.extensions.c.ports.image"]
self.group = "Image Source"
self.properties = [{"name": "Width",
"label": "width",
"type": HARPIA_INT,
"lower": 0,
"upper": 65535,
"step": 1
},
{"name": "Height",
"label": "Height",
"type": HARPIA_INT,
"lower": 0,
"upper": 65535,
"step": 1
}
]
# -------------------C/OpenCv code------------------------------------
self.codes[2] = \
'CvSize size$id$ = cvSize($width$,$height$);\n' + \
'block$id$_img_o0 = cvCreateImage(size$id$,IPL_DEPTH_8U,3);\n' + \
'cvSetZero(block$id$_img_o0);\n'
self.language = "c"
self.framework = "opencv"
示例9: __init__
def __init__(self):
Plugin.__init__(self)
self.x0 = 0
self.y0 = 0
# Appearance
self.help = "Creates a new Point."
self.label = "New Point"
self.color = "50:50:200:150"
self.out_types = ["harpia.extensions.c.ports.point"]
self.group = "Basic Data Type"
self.properties = [{"name": "X",
"label": "x0",
"type": HARPIA_INT,
"lower": 0,
"upper": 65535,
"step": 1
},
{"name": "Y",
"label": "y0",
"type": HARPIA_INT,
"lower": 0,
"upper": 65535,
"step": 1
}
]
# -------------------C/OpenCv code------------------------------------
self.codes[1] = 'CvPoint block$id$_point_o0 = cvPoint($x0$,$y0$);\n'
self.codes[2] = \
'block$id$_point_o0 = cvPoint($x0$,$y0$);\n'
self.language = "c"
self.framework = "opencv"
示例10: __init__
def __init__(self):
Plugin.__init__(self)
self.language = "javascript"
self.framework = "webaudio"
self.help = "Double value"
self.label = "FloatValue"
self.color = "50:150:250:150"
self.out_ports = [{"type":"harpia.extensions.javascript.ports.float",
"label":"Float",
"name":"float"}
]
self.group = "Interface"
self.properties = [{"name": "value",
"label": "Value",
"type": HARPIA_FLOAT,
"lower": 0,
"upper": 20000,
"step": 1,
"value": 1
},
{"name": "min",
"label": "Min",
"type": HARPIA_FLOAT,
"lower": 0,
"upper": 20000,
"step": 1,
"value": 1
},
{"name": "max",
"label": "Max",
"type": HARPIA_FLOAT,
"lower": 00,
"upper": 20000,
"step": 1,
"value": 10
},
{"name": "label",
"label": "Label",
"type": HARPIA_STRING,
"value": "Label"
}
]
self.codes[1] = """
// block_$id$ = Float Value
var block_$id$_value = $prop[value]$;
var $out_ports[float]$ = [];
"""
self.codes[2] = """
function change_$id$_value(){
value = document.getElementById("block_$id$").value;
for (var i = 0; i < $out_ports[float]$.length ; i++){
$out_ports[float]$[i](value);
}
};
"""
self.codes[3] = """
示例11: __init__
def __init__(self):
Plugin.__init__(self)
# Appearance
self.help = "Permite a operação lógica 'OU' entre as " + \
"duas entradas. Para esse bloco há duas possibilidades." + \
"Primeira: Executa a operação entre duas " + \
"imagens ponto a ponto." + \
"Segunda: Executa a operação entre um valor " + \
"constante e cada ponto da imagem."
self.label = "Or"
self.color = "10:180:10:150"
self.in_ports = [{"type":"harpia.extensions.c.ports.image",
"name":"first_image",
"label":"First Image"},
{"type":"harpia.extensions.c.ports.image",
"name":"first_image",
"label":"First Image"}
]
self.out_ports = [{"type":"harpia.extensions.c.ports.image",
"name":"output_image",
"label":"Output Image"}]
self.group = "Arithmetic and logical operations"
self.codes[0] = r"""
// And, Xor, Division, subtraction, sum, or,
//multiplication need images with the same size
void adjust_images_size(IplImage * img1, IplImage * img2, IplImage * img3){
if(img1->width != img2->width || img1->height != img2->height){
int minW,minH;
if(img1->width > img2->width)
minW = img2->width;
else
minW = img1->width;
if(img1->height > img2->height)
minH = img2->height;
else
minH = img1->height;
cvSetImageROI(img2, cvRect( 0, 0, minW, minH ));
cvSetImageROI(img1, cvRect( 0, 0, minW, minH ));
cvSetImageROI(img3, cvRect( 0, 0, minW, minH ));
}
}
"""
self.codes[2] = \
'if(block$id$_img_i0 && block$id$_img_i1){\n' + \
'block$id$_img_o0 = cvCloneImage(block$id$_img_i0);\n' + \
'adjust_images_size(block$id$_img_i0, ' + \
'block$id$_img_i1, block$id$_img_o0);\n' + \
'cvOr(block$id$_img_i0, block$id$_img_i1, ' + \
'block$id$_img_o0,0);\n' + \
'cvResetImageROI(block$id$_img_o0);\n' + \
'}\n'
self.language = "c"
self.framework = "opencv"
示例12: __init__
def __init__(self):
Plugin.__init__(self)
self.language = "javascript"
self.framework = "webaudio"
self.help = "Sound output"
self.label = "Oscillator"
self.color = "50:150:250:150"
self.in_ports = [{"type":"harpia.extensions.javascript.ports.sound",
"label":"Osc Frequency",
"name":"osc_freq"},
{"type":"harpia.extensions.javascript.ports.float",
"label":"Frequency",
"name":"freq"},
{"type":"harpia.extensions.javascript.ports.float",
"name":"type",
"label":"Type"}]
self.out_ports = [{"type":"harpia.extensions.javascript.ports.sound",
"name":"sound",
"label":"Sound"}]
self.group = "Sound"
self.properties = [{"name": "freq",
"label": "Frequency",
"type": HARPIA_FLOAT,
"lower": 0,
"step": 1,
"value": 440
},
{"name": "type",
"label": "Type",
"type": HARPIA_COMBO,
"values": ["square",
"sine",
"sawtooth",
"triangle"],
"value": "sine"
}
]
self.codes[0] = """
// block_$id$ = Oscillator
var block_$id$ = context.createOscillator();
var $in_ports[osc_freq]$ = block_$id$.frequency;
var $out_ports[sound]$ = null;
var $in_ports[freq]$ = function(value){
block_$id$.frequency.value = value;
};
var $in_ports[type]$ = function(value){
oscillator = ''
if (value < 1) oscillator = 'square';
if (value == 1) oscillator = 'sine';
if (value == 2) oscillator = 'sawtooth';
if (value > 2) oscillator = 'triangle';
block_$id$.type = oscillator;
};
"""
self.codes[1] = """
示例13: __init__
def __init__(self):
Plugin.__init__(self)
self.smooth_type = "CV_GAUSSIAN"
self.param1 = 7
self.param2 = 9
# Appearance
self.help = "Aplicação de um filtro de suavização. " + \
"Suaviza os contornos de objetos na imagem, borrando-os levemente."
self.label = "Smooth"
self.color = "50:125:50:150"
self.in_types = ["harpia.extensions.c.ports.image", "harpia.extensions.c.ports.int"]
self.out_types = ["harpia.extensions.c.ports.image", "harpia.extensions.c.ports.int", "harpia.extensions.c.ports.int"]
self.group = "Filters and Color Conversion"
self.properties = [{"name": "Type",
"label": "smooth_type",
"type": HARPIA_COMBO,
"values": ["CV_GAUSSIAN", "CV_BLUR", "CV_MEDIAN"]
},
{"name": "Parameter 1",
"label": "param1",
"type": HARPIA_INT,
"lower": 0,
"upper": 99,
"step": 1
},
{"name": "Parameter 2",
"label": "param2",
"type": HARPIA_INT,
"lower": 0,
"upper": 99,
"step": 1
}
]
# -------------------C/OpenCv code------------------------------------
self.codes[1] = \
'IplImage * block$id$_img_i0 = NULL;\n' + \
'int block$id$_int_i1 = $param1$;\n' + \
'int block$id$_int_i2 = $param2$;\n' + \
'IplImage * block$id$_img_o0 = NULL;\n'
self.codes[2] = \
'\nif(block$id$_img_i0){\n' + \
'block$id$_img_o0 = cvCloneImage(block$id$_img_i0);\n' + \
'block$id$_int_i1 = (block$id$_int_i1 %2 == 0)? ' + \
'block$id$_int_i1 + 1 : block$id$_int_i1;\n' + \
'block$id$_int_i2 = (block$id$_int_i2 %2 == 0)? ' + \
'block$id$_int_i2 + 1 : block$id$_int_i2;\n' + \
'cvSmooth(block$id$_img_i0, block$id$_img_o0, ' + \
'$smooth_type$,block$id$_int_i1,block$id$_int_i2,0,0);\n' + \
'}\n'
self.language = "c"
self.framework = "opencv"
示例14: __init__
def __init__(self):
Plugin.__init__(self)
self.help = "Realiza a aquisição de uma imagem a partir " + \
"de algum dispositivo," + \
"seja este uma mídia ou um dispositivo " + \
"de aquisição de imagens (câmera, scanner)."
self.label = "Video File"
self.color = "50:100:200:150"
self.out_ports = [{"type":"harpia.extensions.c.ports.image",
"name":"output_image",
"label":"Output Image"}]
self.group = "Image Source"
self.properties = [{"name": "File Name",
"label": "filename",
"type": HARPIA_OPEN_FILE,
"value": "/usr/share/harpia/images/vLeft.mpg"
},
{"name": "Reset Key",
"label": "key",
"type": HARPIA_STRING,
"value": "a"
}
]
# -------------------C/OpenCv code------------------------------------
self.codes[1] = \
'CvCapture * block$id$_capture = NULL;\n' + \
'IplImage * block$id$_frame = NULL;\n' + \
'block$id$_capture = cvCreateFileCapture("$filename$");\n' + \
'IplImage * block$id$_img_o0 = NULL; //Capture\n'
self.codes[2] = \
'// Video Mode \n' + \
'if(key == \'$key$\'){\n' +\
'\tcvSetCaptureProperty(block$id$_capture, ' + \
'CV_CAP_PROP_POS_AVI_RATIO , 0);\n' + \
'}\n' + \
'cvGrabFrame(block$id$_capture);\n' + \
'block$id$_frame = cvRetrieveFrame (block$id$_capture);\n' + \
'if(!block$id$_frame){\n' +\
'\tcvSetCaptureProperty(block$id$_capture, ' + \
'CV_CAP_PROP_POS_AVI_RATIO , 0);\n' + \
'\tcontinue;\n' + \
'}\n' + \
'block$id$_img_o0 = cvCloneImage(block$id$_frame);\n'
self.codes[3] = "cvReleaseImage(&block$id$_img_o0);\n"
self.codes[4] = 'cvReleaseCapture(&block$id$_capture);\n'
self.language = "c"
self.framework = "opencv"
示例15: __init__
def __init__(self):
Plugin.__init__(self)
self.channel = "All"
# Appearance
self.help = "Create a representation of the light " + \
"intensity levels as an histogram."
self.label = "Histogram"
self.color = "0:0:0:150"
self.in_types = ["harpia.extensions.c.ports.image"]
self.out_types = ["harpia.extensions.c.ports.image"]
self.group = "Histograms"
self.properties = [{"name": "Channels",
"label": "channel",
"type": HARPIA_COMBO,
"values": ["All",
"Red",
"Green",
"Blue"]
}
]
# -------------------C/OpenCv code------------------------------------
self.codes[1] = \
'IplImage * block$id$_img_i0 = NULL;\n' + \
'IplImage * block$id$_img_o0 = NULL;\n' + \
'CvHistogram * block$id$_histogram;\n' + \
'IplImage * block$id$_SourceCx[] = { NULL, NULL, NULL};\n' + \
'IplImage * block$id$_HistCx[] = { NULL, NULL, NULL};\n' + \
'int block$id$_histogram_size[] = { 255, 255, 255 };\n' + \
'float * block$id$_hist_ranges[] = { NULL, NULL, NULL};\n' + \
'float block$id$_hist_rang[2];\n' + \
'float block$id$_histBin;\n' + \
'float block$id$_histMaxVal;\n' + \
'int block$id$_histV;\n' + \
'int block$id$_plotHistChanIter;\n' + \
'int block$id$_plotHistArrIter;\n'
self.codes[3] = \
'if(block$id$_SourceCx[0]) cvReleaseImage' + \
'(&block$id$_SourceCx[0]);\n' + \
'if(block$id$_SourceCx[1]) cvReleaseImage' + \
'(&block$id$_SourceCx[1]);\n' + \
'if(block$id$_SourceCx[2]) cvReleaseImage' + \
'(&block$id$_SourceCx[2]);\n' + \
'if(block$id$_HistCx[0]) cvReleaseImage' + \
'(&block$id$_HistCx[0]);\n' + \
'if(block$id$_HistCx[1]) ' + \
'cvReleaseImage(&block$id$_HistCx[1]);\n' + \
'if(block$id$_HistCx[2]) ' + \
'cvReleaseImage(&block$id$_HistCx[2]);\n' + \
'if(block$id$_img_i0) cvReleaseImage(&block$id$_img_i0);\n' + \
'if(block$id$_img_o0) cvReleaseImage(&block$id$_img_o0);\n' + \
'cvReleaseHist(&block$id$_histogram);\n'