def imgRename(path):
i=0
"""图像重命名"""
imgList=[os.path.join(path, f) for f in os.listdir(path) if f.endswith('.jpg')]
for i in range(len(imgList)):
print(i)
name=os.path.splitext(imgList[i])[0];
newname=os.path.join(path,str('%06d' % i)+'.jpg')
# print(newname)
os.rename(imgList[i], newname)
def Image_shift(imgpath):
"""
平移变换
:param imgpath:
:return:
"""
img = cv2.imread(imgpath)
rows= img.shape[0]
cols= img.shape[1]
dw=100 #往右平移100
dh=200 #往下平移200
M = np.float32([[1, 0, -dw], [0, 1, -dh]])
dst = cv2.warpAffine(img, M, (cols, rows))
for i in range(0,dh):
for j in range(0,cols):
dst[i][j][:]=dst[dh][j][:]
for i in range(0, rows):
for j in range(0, dw):
dst[i][j][:] = dst[i][dw][:]
#newpath = r'./Image_shift/'+imgpath[-10:]
cv2.imwrite(imgpath,dst)
from xml.etree import ElementTree as ET
def processXml(xmlpath):
tree = ET.parse(xmlpath)
root = tree.getroot()
childs = root.getchildren()
childs[1].text = xmlpath[-10:-4]+'.jpg'
childs[2].text = './VOC2007/JPEGImages/'+childs[1].text
tree.write(xmlpath,'UTF-8')
(3)修改imgflip-Annotations文件夹下xml文件
图形做了水平镜像,所以要修改xml文件夹下的 、、和标签。
from xml.etree import ElementTree as ET
def processXml(xmlpath):
tree = ET.parse(xmlpath)
root = tree.getroot()
childs = root.getchildren()
childs[1].text = xmlpath[-10:-4]+'.jpg'
childs[2].text = './VOC2007/JPEGImages/'+childs[1].text
for i in range(6,len(childs)):
if childs[i].tag == 'object':
child = childs[i].getchildren()
child2 = child[4].getchildren()
wid=int(child2[2].text)-int(child2[0].text)
x0=int(child2[0].text)+wid
x2=int(child2[2].text)-wid
if x0<1275: #1275为图像宽的一半
a=x0+(1275-x0)*2
else:
a=x0-(x0-1275)*2
if x2 < 1275:
b = x2 + (1275 - x2) * 2
else:
b = x2 - (x2 - 1275) * 2
child2[0].text=str(a)
child2[2].text =str(b)
tree.write(xmlpath,'UTF-8')
(4)修改Image_shift-Annotations文件夹下xml文件
图形做了平移,所以要修改xml文件夹下的 、、、、、标签。
from xml.etree import ElementTree as ET
def processXml(xmlpath):
tree = ET.parse(xmlpath)
root = tree.getroot()
childs = root.getchildren()
childs[1].text = xmlpath[-10:-4]+'.jpg'
childs[2].text = './VOC2007/JPEGImages/'+childs[1].text
for i in range(6,len(childs)):
if childs[i].tag == 'object':
child = childs[i].getchildren()
child2 = child[4].getchildren()
child2[0].text=str(int(child2[0].text)-50)
child2[1].text=str(int(child2[1].text)-100)
child2[2].text=str(int(child2[2].text)-50)
child2[3].text=str(int(child2[3].text)-100)
for j in range(4): #检查是否超过了图像边界
if int(child2[j].text)<0 :
child2[j].text='0'
tree.write(xmlpath,'UTF-8')
转自于:http://www.iteye.com/problems/23775
问:
我在开发过程中,使用hql进行查询(mysql5)使用到了mysql自带的函数find_in_set()这个函数作为匹配字符串的来讲效率非常好,但是我直接把它写在hql语句里面(from ForumMemberInfo fm,ForumArea fa where find_in_set(fm.userId,f
1、下载软件 rzsz-3.34.tar.gz。登录linux,用命令
wget http://freeware.sgi.com/source/rzsz/rzsz-3.48.tar.gz下载。
2、解压 tar zxvf rzsz-3.34.tar.gz
3、安装 cd rzsz-3.34 ; make posix 。注意:这个软件安装与常规的GNU软件不
Forwarded port
Private network
Public network
Vagrant 中一共有三种网络配置,下面我们将会详解三种网络配置各自优缺点。
端口映射(Forwarded port),顾名思义是指把宿主计算机的端口映射到虚拟机的某一个端口上,访问宿主计算机端口时,请求实际是被转发到虚拟机上指定端口的。Vagrantfile中设定语法为:
c
Given a 2D board and a word, find if the word exists in the grid.
The word can be constructed from letters of sequentially adjacent cell, where "adjacent" cells are those horizontally or ve