Skip to content

Instantly share code, notes, and snippets.

View vatsan's full-sized avatar

Srivatsan Ramanujam vatsan

View GitHub Profile
@vatsan
vatsan / PyMADlib_Tutorial
Created March 30, 2013 08:09
PyMADlib - Tutorial A Python wrapper for MADlib (http://madlib.net) - an open source library for scalable in-database machine learning algorithms
{
"metadata": {
"name": "PyMADlib"
},
"nbformat": 3,
"nbformat_minor": 0,
"worksheets": [
{
"cells": [
{
{
"metadata": {
"name": "Python awesomeness ;-)"
},
"nbformat": 3,
"nbformat_minor": 0,
"worksheets": [
{
"cells": [
{
{
"metadata": {
"name": "",
"signature": "sha256:50dec51e2d2443c96fa76c4b031cb21c3753b9100182a59e6b2105e0c2c2fc79"
},
"nbformat": 3,
"nbformat_minor": 0,
"worksheets": [
{
"cells": [
@vatsan
vatsan / canny_edge_detection_plpython.cpp
Last active August 29, 2015 14:09
native_apps_blog
/*
* Gautam Muralidhar and Srivatsan Ramanujam, 28 Oct 2014
* C++ functions compiled into dynamic library to be invoked from PL/Python via ctypes.
* Canny Edge Detection from OpenCV.
*/
#include "opencv2/opencv.hpp"
#include "opencv2/imgproc/imgproc.hpp"
#include <stdio.h>
#include <string.h>
#include <iostream>
@vatsan
vatsan / native_apps_blog_canny_plpython.sql
Last active August 29, 2015 14:09
native_apps_blog_canny_plpython
--------------------------------------------------------------------------------------------------------------
-- Gautam Muralidhar, Srivatsan Ramanujam, Oct-2014
-- PL/Python UDF, which calls the native Canny edge detection application
-- Input: the raw image byte stream encoded as a comma-separated string and stored in a column in a HAWQ table
-- Output: a composite type as defined in Figure 5.
--------------------------------------------------------------------------------------------------------------
CREATE OR REPLACE FUNCTION canny_edge_detect(img varchar)
RETURNS canny_output_type
/**
* Gautam Muralidhar,Srivatsan Ramanujam Oct 2014
* PL/C function for invoking Canny's Edge Detection from OpenCV
**/
extern "C" {
#include <postgres.h>
#include <fmgr.h>
#include <utils/array.h>
#include <utils/builtins.h>
#include <catalog/pg_type.h>
/**
* Gautam Muralidhar, Nov 2014
* Internal C++ functions for Canny Edge Detection.
*
**/
#include <iostream>
#include <string>
#include <vector>
#include "opencv2/opencv.hpp"
#include "opencv2/imgproc/imgproc.hpp"
/**
* Gautam Muralidhar, Srivatsan Ramanujam, Nov 2014
* PL/C UDFs to invoke Edge Detection
*/
create or replace function CannyEdgeDetectPLC(varchar)
returns int[]
as
'/usr/local/lib/ds/canny_plc.so', 'canny_plc'
language C strict immutable;
/**
* Gautam Muralidhar, Srivatsan Ramanujam, Nov-2014
* External Table defs.
**/
create external table ocv.src_image_ext
(
img_name varchar,
img varchar
)
LOCATION('pxf://hdm1:50070/user/user-name/opencvexample/imgseqfile/part-r-00000?Profile=HdfsTextSimple')
-- Define a type to hold [tweet_id, token_index, token, tag] items
DROP TYPE IF EXISTS token_tag;
CREATE TYPE token_tag
AS
(
indx int,
token text,
tag text
);