当前位置:网站首页>DonkeyCar source code reading .4 (project file creation)
DonkeyCar source code reading .4 (project file creation)
2022-08-05 13:03:00 【endless clouds】
DonkeyCar源码阅读.3(操作记录+Several image manipulations)
donkeycarOne thing is well done,Each small application generates a library with its own tools,This is the code I read today.
位置在这里,base提供了工具
There are a lot of own libraries at the beginning of the library
from progress.bar import IncrementalBarThis library is a library that displays a progress bar
Such a program can be written
特别的,The gadget gallery here is one thing I love to look at every time
Look at this spelling,The name of the parameter and return value function is written in the string documentation, which is also clear at a glance,归一化图像.
加载一个图像
传入的参数是,The name of the file and a parameter,cfg一般就是config的意思.最后返回一个u8的图像数组.It depends on another function,I'll talk about this below.
Sorry for not having enough choices
在这里有,It is to compare and calculate the parameters of the real image and the parameters we give,如果大小不一致,This will start executing onereszie的工作,The depth channel of the image is then processed.PIL有九种不同模式: 1,L,P,RGB,RGBA,CMYK,YCbCr,I,F.
img.convert('L')
为灰度图像,每个像素用8个bit表示,0表示黑,255表示白,其他数字表示不同的灰度.
转换公式:L = R * 299/1000 + G * 587/1000+ B * 114/1000
About the configuration is actually a more complex file,之后说,Thought I wasn't sure if it was the associated code file.
This is another wrong modified code
Here is the array conversion work on the image,In fact, it means that no matter what, we must ensure the correctness of our return file.
The meaning of this code is actually the code to extend a channel
另外有个math的库,There are several common variables defined in it,都是使用float来定义的
Returns the name of the directory
You can also take a look at the implementation of this function,打印目录的名字
Returns a filesystem representation of a path
words inside,is to use this to achieve
joinis to concatenate multiple paths,Actually add it
包,模板,帮助文件
Create a new directory
This function returns the current directory completion
First print this directory:
如果没有的话,Just create a new directory,之后返回
Load a configuration file
Complete the configuration file and path,Then judge whether the path is really created successfully.Then an error log will be printed,也会打印:There is no configuration file in place.Then return oneNone.
Below is an error handling code,But this function that loads the config,is a new function implemented,It is different from the implementation of the function above itself.Also looked at the west,exceptit's the log,后面都一样了.
这个函数比较大
If the configured path is empty,Just import the following__main__.
__file__表示显示文件当前的位置
但是:
如果当前文件包含在sys.path里面,那么,__file__返回一个相对路径!
如果当前文件不包含在sys.path里面,那么__file__返回一个绝对路径!
Then add the path to it,If it doesn't exist, it will be added again.
This is using a reflection function
https://docs.python.org/zh-cn/3/library/os.path.html?highlight=path#os.path.expanduserhttps://developer.horizon.ai/api/v1/fileData/documents_pi/index.htmlhttps://docs.python.org/zh-cn/3/library/os.path.html?highlight=path#module-os.pathhttps://www.py.cn/jishu/jichu/19324.htmlhttps://www.cnblogs.com/haifwu/p/12825741.html边栏推荐
猜你喜欢
随机推荐
Dialogue with Zhuang Biaowei: The first lesson of open source
MySQL's InnoDB thread model
中信证券ETF基金开户怎么样安全吗
NFT卡牌游戏系统dapp开发NFT链游技术
790. The cube root of a number
比较方法equals( )、==以及CompareTo
RK3588+FPGA high-speed image processing communication processor solution
Top 10 new features in Oracle Database 19c at a glance
MYSQL query duplicate data
How does the bank transaction system ensure strong consistency of data transactions?Via the database component?How to ensure the normal consistency of database transaction data under high concurrency?
TypeScript的崛起之路给我们带来的选谷思路
One: OpenCV image reading and writing file help documentation
《MySQL核心知识》第2章:MySQL常用的命令
到底怎么个DAO
Two: OpenCV image overlay logical operation
MYSQL 查询重复数据
为什么设计思维是有用的?
C进阶-数据的存储(下)
HCIP--BGP小综合实验
2022华数杯C:插层熔喷非织造材料的性能控制研究









