Python之NumPy(axis=0 与axis=1)

axis=0: vertical

axis=1: horizontal


Jupyter Notebook打开默认文件夹以外的文件



修改Jupyter Notebook的默认打开目录


想要打开其他盘符的文件无法实现,如D、E、F盘目录下的文件。现有解决办法如下,无需修改Jupyter Notebook的默认打开路径。


在CMD模式中打开需要打开的目录,然后打开Jupyter Notebook

如果使用的是anaconda则打开anaconda prompt


  • win + R 进入CMD模式,在cmd窗口中输入下面代码即可打开 E盘下的OpenTry文件夹
    • cd /d E:\OpenTry
    • jupyter notebook

jupyter启动目录就变成了 OpenTry,如下图:
启动目录变成了 OpenTry

如果需要打开其他盘符的其他目录,只需要将上面代码中加粗的 E:\OpenTry 改为所需要的位置,如:D:\soft\OpenCV



使用键盘的 Tab键上侧的LaTeX技巧218:LaTeX如何正确输入引号:双引号“”单引号‘’连续键入两个然后输入键盘的两个单引号。单引号输入类似。示例如下:

   \setlength \textwidth{150pt}
   Pumas are “large, cat-like animals” which are `found in America’. When reports came into London Zoo that a wild puma had been spotted forty-five miles south of London, they were not taken seriously. However, as the evidence began to accumulate, experts from the Zoo felt obliged to investigate, for the descriptions given by people who claimed to have seen the puma were extraordinarily similar.

Problems with the video writer

cv::VideoWriter outputVideo(“video.avi”, CV_FOURCC(‘M’, ‘P’,’E’,’G’), 10.0, cv::Size(rows, cols));

This may not write the video.

Try changing fourcc to -1. Then, it will give you a choice of video codecs to use for writing.


  1. The image size and VideoWriter must be correct for framesize argument: OpenCV Error: Sizes of input arguments do not match (image size is different from the currently set frame size) in CvVideoWriter_VFW::writeFrame, file C:\build\2_4_winpack-build-win64-vc14\opencv\modules\highgui\src\cap_vfw.cpp, line 815
  2. The image must be in BGR format or it will not write
  3. Try to use ‘name.avi‘ file name

Inspired by

How to Rotate and/or Flip (Mirror) Images in OpenCV

Copy From


Obviously you’ll start by reading an image from disk, or grab it from a video frame and so on, similar to this:


After that depending on the required transformation use any of the following codes.


Flip (Mirror) Vertically

flip(image, image, 0);


Flip (Mirror) Horizontally

flip(image, image, +1);


Rotate 90 Degrees Clockwise

transpose(image, image);
flip(image, image, +1);


Rotate 90 Degrees Counter Clockwise (Same as -90 Degrees and 270 Degrees)

transpose(image, image);
flip(image, image, 0);


Rotate 180 Degrees (Same as Flipping vertically and horizontally at the same time)

flip(image, image, -1);

[C++ Cookbook by Jeff Cogswell] Parsing a String Containing a Number in Scientific Notation


You have a string containing a number in scientific notation, and you want to store the number’s value in a double variable.


The most direct way to parse a scientific notation number is by using the C++ library’s built-in stringstream class declared in <sstream>, as you can see in Example 3-7.

Example 3-7. Parsing a number in scientific notation

#include <iostream>
#include <sstream>
#include <string>

using namespace std;

double sciToDub(const string& str) {

   stringstream ss(str);
   double d = 0;
   ss >> d;

   if ( {
      string s = "Unable to format ";
      s += str;
      s += " as a number!";
      throw (s);

   return (d);

int main() {

   try {
      cout << sciToDub("1.234e5") << endl;
      cout << sciToDub("6.02e-2") << endl;
      cout << sciToDub("asdf") << endl;
   catch (string& e) {
      cerr << "Whoops: " << e << endl;

Following is the output from this code:

Whoops: Unable to format asdf as a number!