0%

Git is a powerful version management system. This posts captures the common used commands.

Read more »

VS Code is an amazing code editor, which contains various extensions and support multi-languages.

Basic Skills

  • Use Ctrl+Shift+P to open the VSCode command center to input command
  • Use command center and type Open settings(JSON) to edit the VS Code settings
  • Some useful keyboard shortcuts

C#

In order to use VS Code for the C# programming, we need to install

  • .NET Core
  • C# Extension in VS Code

Then open a folder with VS Code, and use the terminal to type dotnet new console to establish a new console project.

Then the VS Code will automatically generate some files and new a Program.cs script.

Go to Dubug-Start without Debuging, VS Code will add the required assets to the project(or press ctrl+shift+p and type .net: Generate Assets for Build and Debug), and open a launch.json file for user to configure some settings of the C# project. Make sure the version of netcore is right. Then cick the Start without Debuging again, the program will run.

Python

For Python, we need to install

  • Python interpreter
  • Python Extension in VS Code

Open a folder and add a python file. Then press ctrl+shift+p to open the command and type Python: select interpreter to choose the python interpreter. Then go to Debug-Start without Debuging to run the code.

LaTex

In order to use Latex, we need to install

  • Tex Environment, like Tex Live
  • Latex Workshop Extension for VS Code

Environment and Packages Management

For environment, you can use virtualenv to create a virtual python environment to seperate this to the original environment.

1
virtualenv XX

Note. the virtual env folder will be located to your current folder of the bash locates. When you change the path of the env folder, it will cause problem for some direct running module. Like pip, jupyter

For packages, you can use the following command to export installed packages in env1 and install those packages in env2

1
2
(env1) $ pip freeze > requirement.txt
(env2) $ pip install -r requirement.text

Opencv has a lot of useful functions.

Show image/video stream

1
2
3
while True:
cv2.imshow(img)
cv2.waitKey(1)

Color Space Convert

1
gray_img = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY)

Histogram and Backprojection

1
2
hist = cv2.calcHist([img], [0, 1], None, [180, 256], [0, 180, 0, 256])
mask = cv2.calcBackProject([target], [0, 1], hist, [0, 180, 0, 256], 1)

Otsu threshold

1
_, mask = cv2.threshold(img[:, :, 1], 0, 255, cv2.THRESH_BINARY | cv2.THRESH_OTSU)

Geometric

Contour of images

1
_, contours, _ = cv2.findContours(mask, cv2.RETR_CCOMP, cv2.CHAIN_APPROX_SIMPLE)

Convex Hull and Convex Defect

1
2
hull = cv2.convexHull(contour, returnPoints=False)
defects = cv2.convexityDefects(contour, hull)