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

axis=0: vertical

axis=1: horizontal

Advertisements

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

转自:https://blog.csdn.net/yefcion/article/details/79431760

 

修改Jupyter Notebook的默认打开目录

Jupyter启动之后默认打开的是C盘目录,如下:
启动目录是C盘

想要打开其他盘符的文件无法实现,如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

 

 


https://blog.csdn.net/yefcion/article/details/79431760

LaTeX如何正确输入引号:双引号“”单引号‘’

转自:http://blog.sina.com.cn/s/blog_5e16f1770100gusb.html

最近看一些latex用户的文章,输入的双引号和单引号都是用输入法中的中文模式键入,并不是LaTeX的正确输入方式。
正确的输入方法如下:
使用键盘的 Tab键上侧的LaTeX技巧218:LaTeX如何正确输入引号:双引号“”单引号‘’连续键入两个然后输入键盘的两个单引号。单引号输入类似。示例如下:
LaTeX技巧218:LaTeX如何正确输入引号:双引号“”单引号‘’

演示代码:
    \documentclass{article}
   \setlength \textwidth{150pt}
   \begin{document}
   \large
   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.
       \end{document}

 


http://blog.sina.com.cn/s/blog_5e16f1770100gusb.html

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 http://answers.opencv.org/question/66545/problems-with-the-video-writer-in-opencv-300/

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

Copy From http://amin-ahmadi.com/2017/06/01/how-to-rotate-andor-flip-mirror-images-in-opencv/

 

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

imread(“/Users/amin/Test.jpg”);

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);

 

 


http://amin-ahmadi.com/2017/06/01/how-to-rotate-andor-flip-mirror-images-in-opencv/

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

Problem

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

Solution

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 (ss.fail()) {
      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:

123400
0.0602
Whoops: Unable to format asdf as a number!

https://www.safaribooksonline.com/library/view/c-cookbook/0596007612/ch03s06.html