Skip to content

Instantly share code, notes, and snippets.

@benblackcake
benblackcake / producer-consumer
Created July 21, 2021 04:14 — forked from ictlyh/producer-consumer
Producer and consumer demo in concurrent queue. c++ multi-threading.
// concurrent-queue.h
#ifndef CONCURRENT_QUEUE_H_
#define CONCURRENT_QUEUE_H_
#include <queue>
#include <thread>
#include <mutex>
#include <condition_variable>
template <typename T>
@benblackcake
benblackcake / README.md
Created May 27, 2020 06:49 — forked from physacco/README.md
Python 3 extension example

Python 3 extension example

Build

python3 setup.py build

Output: build/lib.macosx-10.11-x86_64-3.5/hello.cpython-35m-darwin.so

Run

@benblackcake
benblackcake / PyUtils.cpp
Created May 26, 2020 10:02 — forked from rjzak/PyUtils.cpp
Convert between Python list/tuples and C++ vectors
#include <Python.h> // Must be first
#include <vector>
#include <stdexcept>
#include "PyUtils.h"
using namespace std;
// =====
// LISTS
// =====
@benblackcake
benblackcake / PyUtils.cpp
Created May 26, 2020 10:02 — forked from rjzak/PyUtils.cpp
Convert between Python list/tuples and C++ vectors
#include <Python.h> // Must be first
#include <vector>
#include <stdexcept>
#include "PyUtils.h"
using namespace std;
// =====
// LISTS
// =====
@benblackcake
benblackcake / client.cpp
Created May 20, 2020 19:24 — forked from SteveRuben/client.cpp
Multiple streaming in c++ using opencv; OpenCV video streaming over TCP/IP
/**
* OpenCV video streaming over TCP/IP
* Client: Receives video from server and display it
* by Steve Tuenkam
*/
#include "opencv2/opencv.hpp"
#include <sys/socket.h>
#include <arpa/inet.h>
#include <unistd.h>
@benblackcake
benblackcake / structs_as_functions.cpp
Created May 17, 2020 09:47 — forked from gagolews/structs_as_functions.cpp
operator() for structs in C++
#include <iostream>
#include <vector>
using namespace std;
// an illustration for my Julia-related question on julia-users
struct datfun {
// some data
vector<double> x;
vector<double> y;
@benblackcake
benblackcake / gd_simple.py
Created May 14, 2020 06:28 — forked from DominicBreuker/gd_simple.py
Simple example of gradient descent in tensorflow
import tensorflow as tf
x = tf.Variable(2, name='x', dtype=tf.float32)
log_x = tf.log(x)
log_x_squared = tf.square(log_x)
optimizer = tf.train.GradientDescentOptimizer(0.5)
train = optimizer.minimize(log_x_squared)
init = tf.initialize_all_variables()

Edge Detection Algorithm using OpenCV

評估演算法的依據

  • 雜訊誤判為邊緣(Edge)
  • 沒找出真正邊緣(Edge)

各種邊緣偵測方式

  • Soble
  • Laplacian
  • Canny
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@benblackcake
benblackcake / threadedgenerator.py
Created March 3, 2020 13:54 — forked from everilae/threadedgenerator.py
Threaded generator wrapper for Python
# A simple generator wrapper, not sure if it's good for anything at all.
# With basic python threading
from threading import Thread
try:
from queue import Queue
except ImportError:
from Queue import Queue