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/

Advertisements

Visual studio: set the path to a DLL file in Visual Studio?

 

  1. Under Debugging, there’s an Environment field.
  2. Add your relative path there (relative to vcproj folder) i.e. ..\some-framework\lib by appending PATH=%PATH%;$(ProjectDir)\some-framework\lib or prepending to the path PATH=C:\some-framework\lib;%PATH%

 


https://stackoverflow.com/a/2119707

[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

Disable or increase WDDM TDR Delay

 

Since you’re running on windows, this may be nothing more than you hitting the windows TDR mechanism. Kernels that run longer than about 2 seconds on windows may trigger the TDR mechanism. Usually when this happens, you will see the screen flash to black and then repaint itself, as the GPU goes through the windows-triggered reset. You may also see a systray message. The exact behavior may also be different if you are running the code from within VS versus running from the command line.

Refer to the above link or search on the CUDA tag for how to modify the TDR mechanism.

 


Windows WDDM Driver Timeout Detection and Recovery mechanism can be disabled or the timeout can be extended to be greater than the default 2 seconds.Timeout Detection and Recovery is documented on MSDN.

Nsight Visual Studio Edition Nsight.Monitor has settings to disable or increase the timeout. Otherwise, you can use the registry keys in the MSDN article. Make sure to restart the computer after making changes.

I recommend that you increase TdrDelay before completely disabling TDR.

Tesla GPUs can use the Tesla Compute Cluster driver which does not have a timeout watchdog.

 


https://stackoverflow.com/a/13185441/4862158

Matlab: Extract numbers from a mixed string

teststr = ‘Test setup: MaxDistance = 60 m, Rate = 1.000, Permitted Error = 50 Operator Note: Air Temperature=20 C, Wind Speed 16.375m/s, Altitude 5km (Cloudy)’;
regexp(teststr,[\d])
regexp(teststr,[‘\d’])
regexp(teststr,[‘\d’],’match’)
regexp(teststr,[‘\d+’],’match’)
regexp(teststr,[‘\d+.?’],’match’)
regexp(teststr,[‘\d+\.?’],’match’)
regexp(teststr,[‘\d+\.?\d?’],’match’)
regexp(teststr,[‘\d+\.?\d+?’],’match’)
regexp(teststr,[‘\d+\.?\d*?’],’match’)
regexp(teststr,[‘\d+\.?\d?’],’match’)
regexp(teststr,[‘\d+\.?\d*’],’match’)

 


https://www.mathworks.com/matlabcentral/answers/44049-extract-numbers-from-mixed-string#answer_54043