OpenCV cheat sheet

image I/O

cv2.imread()

Syntax: cv2.imread(path, flag)

Parameters:

  1. path
  2. flag: It specifies the way in which image should be read. It’s default value is cv2.IMREAD_COLOR

cv2.IMREAD_COLOR:It specifies to load a color image, default flag, alternatively, we can pass 1 for this flag.

cv2.IMREAD_GRAYSCALE: It specifies to load an image in grayscale mode. Alternatively pass value 0.

cv2.IMREAD_UNCHANGED: It specifies to load an image including alpha channel.

Return Value: returns an image

Click to read more ...

OOP Comparison between C++ and Python

  1. Inheritance
  2. Polymorphism
  3. Encapsulation
  4. Abstraction

class definition

C++

//class
class Points
{
public:
	//constructor
	Points(int x, int y){
		this->_x = x;
		this->_y = y;
	}

	//print function
	void print() const{
		std::cout<<this->_x<<" "<<this->_y<<std::endl;
	}
	//public data members
	string alias = "position of point";
private:
	//private data members
	int _x;
	int _y;
};
Click to read more ...

Convolutional Neural Network from Scratch, Keras&Tensorflow

image I/O

cv2.imread()

Syntax: cv2.imread(path, flag)

Parameters:

  1. path
  2. flag: It specifies the way in which image should be read. It’s default value is cv2.IMREAD_COLOR

cv2.IMREAD_COLOR:It specifies to load a color image, default flag, alternatively, we can pass 1 for this flag.

cv2.IMREAD_GRAYSCALE: It specifies to load an image in grayscale mode. Alternatively pass value 0.

cv2.IMREAD_UNCHANGED: It specifies to load an image including alpha channel.

Return Value: returns an image

image basic operation

rotate cv2.rotate()

Syntax: cv2.rotate(src, rotateCode)

Parameters:

  1. src: t is the image whose color space is to be changed

  2. rotateCode: It is an enum to specify how to rotate the array.

  • cv2.ROTATE_()_CLOCKWISE
  • cv2.ROTATE_()_COUNTERCLOCKWISE
  • cv2.ROTATE_180

Return value: It returns an image

Click to read more ...

Decision Tree

example

Color Diameter Label
Green 3 Apple
Yellow 3 Apple
Red 1 Grape
Red 1 Grape
Yellow 3 Lemon

Difficulties: No visual way to seperate features since sample 2 and sample 5 share the same features while having different labels

Family of Decision Tree Learning Algorithms:

  • ID3
  • C4.5
  • C5.0
  • CART
Click to read more ...

SSH Keys

Problem

How to create multiple github accounts and git push or pull automatically?

Solution

generate different ssh key

ssh-keygen -t rsa -C "Hadley_hzy@hotmail.com"
ssh-keygen -t rsa -C "Hou.z@husky.neu.edu"

for example, 2 keys created:

~/.ssh/id_rsa_hadleyhzy
~/.ssh/id_rsa_hadleyhzy34
Click to read more ...