A quick way to understand Python scripts is to run a sample program.
Even if you don't immediately know what the function arguments and return values mean, Python's integrated environment Spyder allows you to quickly see variables, data types, and their values.
if __name__ == '__main__'
:
The variables that appear in the block of are still on the Python interpreter even after this block has been executed.
Therefore, if you print the variable on the interpreter, you can refer to the value.
On the contrary, in the Spyder integrated environment, when you display Variable Explorer, the type, size, and value of all variables in the interpreter's memory are displayed. It is also displayed in a data structure such as a list consisting of arrays.
import pylab After pylab.imshow(img) Alternatively, do the following: import matplotlib.pyplot as plt plt.imshow(img)
(For example, when you get a parallax image from a stereo image, some algorithms have parallax values that are integers, others have floating point numbers. Some algorithms work well with just the right initial values, but others. The value doesn't work. You can see that by trying it.)
And by typing into Spyder's IPython console You can also display the post-operation variable as an image if it is an image, without modifying the original script.
In python Output = function (input argument) So, along with the fact that the data dependencies are easy to understand Good for understanding algorithms. Since it is a script language, there is no discrepancy between the executed script and the execution result. Good for understanding algorithms.
Rather than trying to run an OpenCV C ++ sample program First of all, it is recommended to run the sample of OpenCV in Python. And when you understand the input and output of the module's functions, I would like to read the C ++ source code of the module.
Summary -Variable type, size, and value can be confirmed in Variable Explorer of Spyder integrated environment. -When variables remain on the interpreter after executing the script On the IPython console import matplotlib.pyplot as plt plt.imshow(img) You can check the value as.
Recommended Posts