Ⅰ opencv 用python 使用surf算法计算出了最后的结果,绘出了图像,之后怎么找出目标位置
这个用不着SURF。只需要聚色彩就可以了。芬达主要由橙色与黑色组成。只需要按橙色与黑色设计两个向量指标,立刻就可以看出来,只有芬达同时符合这两个峰值。
你显然没有做过数据处理的经验。这个东西。甚至用不着opencv的核心功能。只需要用它的图像采集然后处理一下图像就可以了。
当然芬达是一个对象。你还需要将对象与背景分享出来。这个时候,可以使用一些类似人脸识别的算法。
但是换作是我自己。显然不会这样做。我只需要计算颜色距离相似度。把相似的颜色自动分成区域。然后计算区域的重心与离散度。就可以轻松分离出哪些区域是背景,哪些是对象。
Ⅱ python 循环处理代码如何编写
写个匹配函数,传参是两个图,返回成功或者失败。
然后把23456789....图片放在列表里,for循环去调用匹配函数,匹配到了就退出,没有就继续
Ⅲ 求Python大神帮我解释下代码,急
函数名 gameOver,参数playSurface
设置提示字体格式
设置提示颜色
设置提示位置
绑定以上设置到句柄
运行提示信息
进程挂起5ms
游戏退出
系统退出
Ⅳ 用Python画出双叶双曲面x^2/16 y^2/25-z^2/36=-1的图像的过程
半球面: [ fia,theta ] = meshgrid ([ linspace (0,pi,100) ,pi ]) ; x = sin (theta)。* cos (fia) ; y = sin (theta).* sin (fia) ; z = cos (theta) ; surf (x,y,z)遮蔽球面: theta = 0:0.1:2 * pi; phi = theta’ ; x = cos (phi) * cos (theta) ; y = cos () * sin (theta) ; z = sin () * ones (theta) ; mesh (x,y,z) ; interp 双曲面: surf (’8 * tan (u) * cos (v)’ ,’8。* tan (u) * sin (v)’ ,’2。* sec (u)’ ,[-pi。/2,3 * pi./2,0,2 * pi ]) axis equalgrid onsquareexlabel (’ x axis’) ; ylabel (’ y axis’) ; zlabel (’ z axis’) ; title (’双曲面’)
Ⅳ 为什么python 不生成可执行文件
有了python27/python33,有了集成开发环境eclipse/pydev, pycharm,安装了各种package (pythonxy我就不试了,太大了)
接下来就是如何生成exe文件,没有python的电脑windows下也能用. 古人云, 如果不能下跪行礼,则要此膝何用? 套用一下,如果不能编译到exe,则要此IDE何用?
支持这种py 到 exe 转换的网上看了有很多, py2exe从2008年就没有人维护了; 剩下还有维护的为数不多的几个之一pyinstaller
如何安装?
安装的时候其实是在windows CMD命令行console窗口里用类似DOS的方式完成的.不是在python的console命令行
从py到exe通过pyinstaller如何转换的英文版:
也是以cmd.exe的console窗口命令行实现.
比如, 在pyinstaller-2.1>解压缩的文件夹里, 而python27;python33安装在另外一个路径,环境变量没有设置
操作方式是这样的: cmd.exe运行起来, cd转到 比如 D:>packages>pyinstaller-2.1>为当前路径
然后输入:
C:python27python.exe pyinstaller.py-w--onefile--icon="my.ico" yourscript.py
增加--icon选项需要自己提供一图标文件my.ico放在pyinstaller-2.1>当前路径下, 连同需要转exe的 yourscript.py
[python]view plain
frommpl_toolkits.mplot3dimportAxes3D
frommatplotlibimportcm
frommatplotlib.tickerimportLinearLocator,FormatStrFormatter
importmatplotlib.pyplotasplt
importnumpyasnp
fig=plt.figure()
ax=fig.gca(projection='3d')
X=np.arange(-5,5,0.25)
Y=np.arange(-5,5,0.25)
X,Y=np.meshgrid(X,Y)
R=np.sqrt(X**2+Y**2)
Z=np.sin(R)
surf=ax.plot_surface(X,Y,Z,rstride=1,cstride=1,cmap=cm.coolwarm,
linewidth=0,antialiased=False)
ax.set_zlim(-1.01,1.01)
ax.zaxis.set_major_locator(LinearLocator(10))
ax.zaxis.set_major_formatter(FormatStrFormatter('%.02f'))
fig.colorbar(surf,shrink=0.5,aspect=5)
plt.show()
经过漫长的(相对较长,跟C++编译一个小project的耗时有一拼)等待之后, 得到一个yourscript的文件夹,下面包含exe及其它文件.
我对一个用matplotlib绘制三维曲面的python代码作了尝试,小小的几行代码转成exe文件之后,就是直奔30MB的小胖子.有得有失.
编译成exe往往期望比脚本的效率高,但是事实可能并不如人意. pyinstaller形式的exe,似乎没有做代码优化,效率不见得比脚本好.
ython/387-create-a-microsoft-windows-7-executable-with-pyinstaller
Create a Microsoft Windows (7) executable with PyInstaller
CREATED ON 06 MARCH 2012
In this article you will see how one could create an executable of some program written in the Python language. The goal is to make some distribuable executable that will work on other Microsoft Windows systems where Python isn't installed.
The content of this article has been written on and for a Microsoft Windows operating system. It should be doable on a GNU/Linux system but i didn't tested. Anyway, creating an all in one executable binary file of Python code isn't that usual on GNU/Linux systems. GNU/Linux guru's would be able to know the equivalent commands.
There ispy2exewhich is able to build executable from Python code. However, for PyQT this seems to fail. On the website ofRiverbank, you will see in the3rd Party Softwaremenu, a link pointing toPyInstaller. Download thePyInstallerzip file, extract it somewhere and place the extracted content where you want. At the time of writting this, i got PyInstaller 1.5.1. PyInstaller isn't an Python mole, so it doesn't need to go into the Python's site-packages. Store PyInstaller at a place that is easy to type on the command prompt. Mind to avoid a too deep path and eventual user rights issues. Here i have put PyInstaller on the root of myD:
Then the first time, you need to configure PyInstaller. This should happen once. At least for each Python version you may have. Or happen each time the PyInstaller config change. For example, if you have already configured OyInstaller and move OyInstaller, you need to reconfigure it. Start a command line interface (CTRL+Rand entercmd). cd (browse with the command cd) to the location where you stored the PyInstaller and execute (configure) like following:
Note: If you use multiples versions of Python on the same machine, you should make multiples copies of PyInstaller and name it differently. That to keeps stuff consistent and avoid weird issues. You should then also always start the python executable with it's version number, for example,python2.6 pyinstaller.pyorpython3.2 pyinstaller.py
Now you can build your Qt application as following. The short way could be (which would be also the way to go in future versions of PyInstaller):
This will create a directory the directory where yourpyinstaller.pyis located. You can double click on your exe and it will run your program. All Python code you will build as executable will be stored in the PyIstaller directory tree. I didn't find a way to change that, but it isn't that bad either.
In the long run, it's more wize to create a build config file for you project. We will use the fancybrower QT example now, which is stored in your Python install if you have installed PyQt (../site-). We the fancybrowser data somerwhere and then run:
The--onefile, like it say, will create one exe file containing all data (dlls and python related stuff). That is probably the most desirable way for Windows users. The-wwill make in sort that no black console window is show and only start the main exe. Getting two window, where one is useless is not proffesional at all.
Now we can run the build with:
Which will now proce the fancybrowser exe inD:pyinstaller-1.5.1fancybrowserdist. Start the exe and it should work! :) BTW, the final exe is about20,5MBinstead of a bunch of files (see first method) with a total size of54,2MB.
Ofcourse, for more information, check the website ofPyInstaller!
Add comment
Ⅵ python,get_rect()的作用是什么,外接矩形又是什么意思
你问的应该是pygame.Surface.get_rect(),这个函数返回当前面的一个长方形。
例如'mysurf.get_rect(center=(100,100)),你会创建一个位于surface中央的长方形。
外接矩形说的一般是某个轮廓的最小外接矩形,就是最小的能包含那个轮廓的矩形。
Ⅶ python pygame运行问题
updates=sprites.draw(screen) 这是只画了屏幕,就是白色的部分,虽然加载图片了,但是并没有blit到screen上,试下screen.blit(weight_image,(0,0)),就会被添加到屏幕上了
Ⅷ Python如何实现图片特征点匹配
python-opencv-特征点匹配连线(画线)drawMatches
Python 没有OpenCV 2.4.13版本的cv2.drawMatches(),无法直接使用,故可参看本文第2节的drawMatches函数使用
Python 有OpenCV 3.0.0版本的cv2.drawMatches(),可以直接使用
1、drawMatches数据结构(opencv2.4.13)
Draws the found matches of keypoints from two images.
C++:
Parameters:
img1– First source image.
keypoints1– Keypoints from the first source image.
img2– Second source image.
keypoints2– Keypoints from the second source image.
matches1to2– Matches from the first image to the second one, which means that keypoints1[i] has a corresponding point in keypoints2[matches[i]] .
outImg – Output image. Its content depends on the flags value defining what is drawn in the output image. See possible flags bit values below.
matchColor– Color of matches (lines and connected keypoints). If matchColor==Scalar::all(-1) , the color is generated randomly.
singlePointColor – Color of single keypoints (circles), which means that keypoints do not have the matches. If singlePointColor==Scalar::all(-1) , the color is generated randomly.
matchesMask– Mask determining which matches are drawn. If the mask is empty, all matches are drawn.
flags– Flags setting drawing features. Possible flags bit values are defined by DrawMatchesFlags.
This function draws matches of keypoints from two images in the output image. Match is a line connecting two keypoints (circles). The structure DrawMatchesFlags is defined as follows:
2、drawMatches(python实现)
Ⅸ python与gsl 科学计算 哪个更好
surf和mesh两个函数创建的都是surface对象,差别仅仅在于: mesh创建的面重点突出网格线(使用不同的颜色表示z轴坐标值),面则设为白色; surf创建的面重点突出曲面本身,而网格线则设为黑色。