数显千分表测量泵箱步进精度使用数显千分表矫正泵箱进程【合并采集数据图片】采集程序#!/usr/local/bin/python# -*- coding: gbk -*-## TEST1.PY -- by Dr. ZhuoQing 2026-06-08## Note:#fromheadmimport*importserialfrom_astimportOrfromserial.serialutilimportSerialExceptionimportserialfrom_astimportOrfromserial.serialutilimportSerialException#------------------------------------------------------------#------------------------------------------------------------cportserial.Serial()cport.baudrate115200cport.timeout0.05try:cport.portCOM4except:printf(Set cport port COM4 error. )try:cport.open()exceptserial.serialutil.SerialException:printf(Open cport port COM4 error.)else:printf(Open cport port COM4 Ok.)#------------------------------------------------------------imgdirrd:\temp\imgdataforiinrange(500):cport.write(bm u 1\r)time.sleep(1)fnameos.path.join(imgdir,%d.jpg%i)tspsavecutimage(fname)printff(i)#------------------------------------------------------------printf(\a)#------------------------------------------------------------# END OF FILE : TEST1.PY#合并算法1.0440,1.0435,1.0525,1.0670,1.0840,1.1050,1.1220,1.1420,1.1620,1.1670,1.2030,1.2220,1.2420,1.2620,1.2805,1.3025,1.3215,1.3405,1.3610,1.3810,1.4025,1.4215,1.4420,1.4625,1.4805,1.5025,1.5205,1.5395,1.5600,1.5785,1.5985,1.6180,1.6365,1.6570,1.6760,1.6950,1.7145,1.7330,1.7530,1.7720,1.7910,1.8110,1.8295,1.8495,1.8690,1.8885,1.9085,1.9275,1.9485,1.9670,1.9865,2.0070,2.0250,2.0465,2.0645,2.0845,2.1050,2.1240,2.1455,2.1650,2.1855,2.2065,2.2260,2.2480,2.2680,2.2885,2.3085,2.3280,2.3510,2.3710,2.3920,2.4130,2.4330,2.4530,2.4735,2.4930,2.5135,2.5330,2.5535,2.5730,2.5935,2.6135,2.6335,2.6530,2.6730,2.6930,2.7130,2.7325,2.7520,2.7720,2.7920,2.8110,2.8315,2.8505,2.8715,2.8890,2.9095,2.9290,2.9490,2.9690,3.0885,3.0805,3.0275,3.0465,3.0665,3.0865,3.1065,3.1260,3.1465,3.1650,3.1860,3.2050,3.2260,3.2440,3.2605,3.2740,3.2875,3.3005,3.3170,3.3330,3.3555,3.3820,3.4040,3.4255,3.4550,3.4795,3.4980,3.5180,3.5370,3.5560,3.5770,3.5960,3.6165,3.6360,3.6545,3.6755,3.6940,3.7155,3.7345,3.7540,3.7750,3.7945,3.8140,3.8340,3.8540,3.8745,3.8945,3.9145,3.9355,3.9560,3.9755,3.9955,4.0160,4.0360,4.0575,4.0770,4.0980,4.1190,4.1385,4.1600,4.1805,4.2100,4.2220,4.2420,4.2635,4.2840,4.3045,4.3250,4.3450,4.3660,4.3860,4.4060,4.4265,4.4460,4.4670,4.4865,4.5065,4.5260,4.5445,4.5645,4.5850,4.6045,4.6255,4.6440,4.6635,4.6825,4.7010,4.7200,4.7390,4.7590,4.7780,4.7970,4.8155,4.8345,4.8525,4.8725,4.8910,4.9100,4.9290,4.9480,4.9675,4.9855,5.0060,5.0245,5.0435,5.0640,5.0820,5.1030,5.1210,5.1420,5.1615,5.1810,5.2015,5.2205,5.2420,5.2610,5.2810,5.3015,5.3210,5.3420,5.3615,5.3805,5.4015,5.4210,5.4405,5.4610,5.4805,5.5010,5.5205,5.5390,5.5610,5.5800,5.6000,5.6205,5.6390,5.6610,5.6790,5.6990,5.7185,5.7310,5.7585,5.7765,5.7975,5.8165,5.8355,5.8575,5.8760,5.8960,5.9160,5.9345,5.9565,5.9745,5.9940,6.0140,6.0325,6.0545,6.0725,6.0925,6.1135,6.1320,6.1545,6.1735,6.1935,6.2155,6.2340,6.2555,6.2745,6.2945,6.3160,6.3345,6.3555,6.3745,6.3945,6.4155,6.4345,6.4555,6.4750,6.4935,6.5140,6.5330,6.5525,6.5725,6.5915,6.6110,6.6300,6.6495,6.6690,6.6880,6.7075,6.7265,6.7460,6.7660,6.7840,6.8045,6.8235,6.8430,6.8625,6.8815,6.9020,6.9215,6.9415,6.9620,6.9815,7.0020,7.0220,7.0415,7.0625,7.0825,7.1040,7.1240,7.1450,7.1660,7.1860,7.2075,7.2285,7.2485,7.2685,7.2880,7.3110,7.3310,7.3510,7.3730,7.3930,7.4130,7.4335,7.4545,7.4725,7.4935,7.5130,7.5320,7.5530,7.5710,7.5920,7.6105,7.6310,7.6505,7.6695,7.6900,7.7090,7.7290,7.7495,7.7680,7.7880,7.8075,7.8270,7.8460,7.8660,7.8845,7.9035,7.9230,7.9415,7.9625,7.9815,8.0005,8.0205,8.0390,8.0590,8.0790,8.0980,8.1180,8.1375,8.1575,8.1770,8.1965,8.2160,8.2350,8.2535,8.2705,8.2860,8.2990,8.3150,8.3300,8.3465,8.3695,8.3985,8.4190,8.4425,8.4685,8.4875,8.5055,8.5265,8.5455,8.5660,8.5865,8.6055,8.6270,8.6465,8.6670,8.6870,8.7010,8.7280,8.7475,8.7680,8.7885,8.8080,8.8285,8.8480,8.8685,8.8890,8.9095,8.9295,8.9500,8.9710,8.9905,9.0115,9.0310,9.0515,9.0720,9.0915,9.1130,9.1330,9.1540,9.1740,9.1930,9.2155,9.2340,9.2540,9.2750,9.2950,9.3160,9.3365,9.3560,9.3770,9.3975,9.4180,9.4380,9.4575,9.4775,9.4980,9.5100,9.5370,9.5550,9.5755,9.5960,9.6155,9.6345,9.6535,9.6725,9.6905,9.7085,9.7275,9.7465,9.7660,9.7845,9.8030,9.8225,9.8405,9.8600,9.8795,9.8990,9.9180,9.9360,9.9560,9.9750,9.9935,10.0135,10.0320,10.0520,10.0715,10.0910,10.1115,10.1300,10.1520,10.1720,10.1915,10.2125,10.2315,10.2530,10.2730,10.2925,10.3140,10.3320,10.3535,10.3720,10.3915,10.4125,10.4310,10.4520,10.4725,10.4915,10.5135,10.5315,10.5515,10.5735,10.5915,10.6140,10.6325,10.6520,10.6720,10.6905,10.7110,10.7290,10.7480,10.7685,10.7850,10.8075,10.8250,10.8440,10.8625,10.8815识别图片中七段数码管数字 以10开头的共有六位数字其他都是五位数字。所有数码管按照整数.四位小数格式整理。总共10列50行将识别的500个数字形成文本便于拷贝。#!/usr/local/bin/python# -*- coding: gbk -*-## TEST3.PY -- by Dr. ZhuoQing 2026-06-08## Note:#fromheadmimport*strid8d[float(s)forsintspgetdopstring(strid).split(,)]plt.plot(d)plt.xlabel(N,colorsteelblue,fontsize24)plt.ylabel(Data,colorsteelblue,fontsize24)plt.grid(True,whichboth,linestyle--,alpha0.7)plt.tight_layout()plt.show()#------------------------------------------------------------# END OF FILE : TEST3.PY#▲ 图2.1 识别结果▲ 图2.2 线性误差曲线※总结 ※#!/usr/local/bin/python# -*- coding: gbk -*-## IMGALL.PY -- by Dr. ZhuoQing 2026-06-08## Note:#fromheadmimport*fromPILimportImage#------------------------------------------------------------imgdirrd:\temp\imgdataiflen(sys.argv)1:imgdirrd:\temp\%s%sys.argv[1]#------------------------------------------------------------fdimos.listdir(imgdir)fnum[int(fn.split(.)[0])forfninfdim]fnumsorted(fnum)fextfdim[0].split(.)[-1]#------------------------------------------------------------f0nameos.path.join(imgdir,%d.%s%(0,fext))f0imImage.open(f0name)printf(f0im.size)blockspace20imgnumlen(fnum)imagecol10imagerow(imgnumimagecol-1)//imagecol imgallwidthf0im.size[0]*imagecolblockspace*(imagecol-1)imgallheightf0im.size[1]*imagerowblockspace*(imagerow-1)printf(imgallwidth,imgallheight)#------------------------------------------------------------imgallImage.new(modeRGB,size(imgallwidth,imgallheight),color(255,255,255))foriinrange(imagerow):forjinrange(imagecol):imgidi*imagecoljifimgidimgnum:breakfnameos.path.join(imgdir,%d.%s%(imgid,fext))fimImage.open(fname)xj*(f0im.size[0]blockspace)yi*(f0im.size[1]blockspace)imgall.paste(fim,(x,y))#------------------------------------------------------------outfilerd:\temp\imgall.jpgiflen(sys.argv)2:outfilerd:\temp\%s.jpg%sys.argv[2]imgall.save(outfile)#------------------------------------------------------------printf(\a)#------------------------------------------------------------# END OF FILE : IMGALL.PY#
合并采集数据图片进展AI识别
发布时间:2026/6/8 21:57:53
数显千分表测量泵箱步进精度使用数显千分表矫正泵箱进程【合并采集数据图片】采集程序#!/usr/local/bin/python# -*- coding: gbk -*-## TEST1.PY -- by Dr. ZhuoQing 2026-06-08## Note:#fromheadmimport*importserialfrom_astimportOrfromserial.serialutilimportSerialExceptionimportserialfrom_astimportOrfromserial.serialutilimportSerialException#------------------------------------------------------------#------------------------------------------------------------cportserial.Serial()cport.baudrate115200cport.timeout0.05try:cport.portCOM4except:printf(Set cport port COM4 error. )try:cport.open()exceptserial.serialutil.SerialException:printf(Open cport port COM4 error.)else:printf(Open cport port COM4 Ok.)#------------------------------------------------------------imgdirrd:\temp\imgdataforiinrange(500):cport.write(bm u 1\r)time.sleep(1)fnameos.path.join(imgdir,%d.jpg%i)tspsavecutimage(fname)printff(i)#------------------------------------------------------------printf(\a)#------------------------------------------------------------# END OF FILE : TEST1.PY#合并算法1.0440,1.0435,1.0525,1.0670,1.0840,1.1050,1.1220,1.1420,1.1620,1.1670,1.2030,1.2220,1.2420,1.2620,1.2805,1.3025,1.3215,1.3405,1.3610,1.3810,1.4025,1.4215,1.4420,1.4625,1.4805,1.5025,1.5205,1.5395,1.5600,1.5785,1.5985,1.6180,1.6365,1.6570,1.6760,1.6950,1.7145,1.7330,1.7530,1.7720,1.7910,1.8110,1.8295,1.8495,1.8690,1.8885,1.9085,1.9275,1.9485,1.9670,1.9865,2.0070,2.0250,2.0465,2.0645,2.0845,2.1050,2.1240,2.1455,2.1650,2.1855,2.2065,2.2260,2.2480,2.2680,2.2885,2.3085,2.3280,2.3510,2.3710,2.3920,2.4130,2.4330,2.4530,2.4735,2.4930,2.5135,2.5330,2.5535,2.5730,2.5935,2.6135,2.6335,2.6530,2.6730,2.6930,2.7130,2.7325,2.7520,2.7720,2.7920,2.8110,2.8315,2.8505,2.8715,2.8890,2.9095,2.9290,2.9490,2.9690,3.0885,3.0805,3.0275,3.0465,3.0665,3.0865,3.1065,3.1260,3.1465,3.1650,3.1860,3.2050,3.2260,3.2440,3.2605,3.2740,3.2875,3.3005,3.3170,3.3330,3.3555,3.3820,3.4040,3.4255,3.4550,3.4795,3.4980,3.5180,3.5370,3.5560,3.5770,3.5960,3.6165,3.6360,3.6545,3.6755,3.6940,3.7155,3.7345,3.7540,3.7750,3.7945,3.8140,3.8340,3.8540,3.8745,3.8945,3.9145,3.9355,3.9560,3.9755,3.9955,4.0160,4.0360,4.0575,4.0770,4.0980,4.1190,4.1385,4.1600,4.1805,4.2100,4.2220,4.2420,4.2635,4.2840,4.3045,4.3250,4.3450,4.3660,4.3860,4.4060,4.4265,4.4460,4.4670,4.4865,4.5065,4.5260,4.5445,4.5645,4.5850,4.6045,4.6255,4.6440,4.6635,4.6825,4.7010,4.7200,4.7390,4.7590,4.7780,4.7970,4.8155,4.8345,4.8525,4.8725,4.8910,4.9100,4.9290,4.9480,4.9675,4.9855,5.0060,5.0245,5.0435,5.0640,5.0820,5.1030,5.1210,5.1420,5.1615,5.1810,5.2015,5.2205,5.2420,5.2610,5.2810,5.3015,5.3210,5.3420,5.3615,5.3805,5.4015,5.4210,5.4405,5.4610,5.4805,5.5010,5.5205,5.5390,5.5610,5.5800,5.6000,5.6205,5.6390,5.6610,5.6790,5.6990,5.7185,5.7310,5.7585,5.7765,5.7975,5.8165,5.8355,5.8575,5.8760,5.8960,5.9160,5.9345,5.9565,5.9745,5.9940,6.0140,6.0325,6.0545,6.0725,6.0925,6.1135,6.1320,6.1545,6.1735,6.1935,6.2155,6.2340,6.2555,6.2745,6.2945,6.3160,6.3345,6.3555,6.3745,6.3945,6.4155,6.4345,6.4555,6.4750,6.4935,6.5140,6.5330,6.5525,6.5725,6.5915,6.6110,6.6300,6.6495,6.6690,6.6880,6.7075,6.7265,6.7460,6.7660,6.7840,6.8045,6.8235,6.8430,6.8625,6.8815,6.9020,6.9215,6.9415,6.9620,6.9815,7.0020,7.0220,7.0415,7.0625,7.0825,7.1040,7.1240,7.1450,7.1660,7.1860,7.2075,7.2285,7.2485,7.2685,7.2880,7.3110,7.3310,7.3510,7.3730,7.3930,7.4130,7.4335,7.4545,7.4725,7.4935,7.5130,7.5320,7.5530,7.5710,7.5920,7.6105,7.6310,7.6505,7.6695,7.6900,7.7090,7.7290,7.7495,7.7680,7.7880,7.8075,7.8270,7.8460,7.8660,7.8845,7.9035,7.9230,7.9415,7.9625,7.9815,8.0005,8.0205,8.0390,8.0590,8.0790,8.0980,8.1180,8.1375,8.1575,8.1770,8.1965,8.2160,8.2350,8.2535,8.2705,8.2860,8.2990,8.3150,8.3300,8.3465,8.3695,8.3985,8.4190,8.4425,8.4685,8.4875,8.5055,8.5265,8.5455,8.5660,8.5865,8.6055,8.6270,8.6465,8.6670,8.6870,8.7010,8.7280,8.7475,8.7680,8.7885,8.8080,8.8285,8.8480,8.8685,8.8890,8.9095,8.9295,8.9500,8.9710,8.9905,9.0115,9.0310,9.0515,9.0720,9.0915,9.1130,9.1330,9.1540,9.1740,9.1930,9.2155,9.2340,9.2540,9.2750,9.2950,9.3160,9.3365,9.3560,9.3770,9.3975,9.4180,9.4380,9.4575,9.4775,9.4980,9.5100,9.5370,9.5550,9.5755,9.5960,9.6155,9.6345,9.6535,9.6725,9.6905,9.7085,9.7275,9.7465,9.7660,9.7845,9.8030,9.8225,9.8405,9.8600,9.8795,9.8990,9.9180,9.9360,9.9560,9.9750,9.9935,10.0135,10.0320,10.0520,10.0715,10.0910,10.1115,10.1300,10.1520,10.1720,10.1915,10.2125,10.2315,10.2530,10.2730,10.2925,10.3140,10.3320,10.3535,10.3720,10.3915,10.4125,10.4310,10.4520,10.4725,10.4915,10.5135,10.5315,10.5515,10.5735,10.5915,10.6140,10.6325,10.6520,10.6720,10.6905,10.7110,10.7290,10.7480,10.7685,10.7850,10.8075,10.8250,10.8440,10.8625,10.8815识别图片中七段数码管数字 以10开头的共有六位数字其他都是五位数字。所有数码管按照整数.四位小数格式整理。总共10列50行将识别的500个数字形成文本便于拷贝。#!/usr/local/bin/python# -*- coding: gbk -*-## TEST3.PY -- by Dr. ZhuoQing 2026-06-08## Note:#fromheadmimport*strid8d[float(s)forsintspgetdopstring(strid).split(,)]plt.plot(d)plt.xlabel(N,colorsteelblue,fontsize24)plt.ylabel(Data,colorsteelblue,fontsize24)plt.grid(True,whichboth,linestyle--,alpha0.7)plt.tight_layout()plt.show()#------------------------------------------------------------# END OF FILE : TEST3.PY#▲ 图2.1 识别结果▲ 图2.2 线性误差曲线※总结 ※#!/usr/local/bin/python# -*- coding: gbk -*-## IMGALL.PY -- by Dr. ZhuoQing 2026-06-08## Note:#fromheadmimport*fromPILimportImage#------------------------------------------------------------imgdirrd:\temp\imgdataiflen(sys.argv)1:imgdirrd:\temp\%s%sys.argv[1]#------------------------------------------------------------fdimos.listdir(imgdir)fnum[int(fn.split(.)[0])forfninfdim]fnumsorted(fnum)fextfdim[0].split(.)[-1]#------------------------------------------------------------f0nameos.path.join(imgdir,%d.%s%(0,fext))f0imImage.open(f0name)printf(f0im.size)blockspace20imgnumlen(fnum)imagecol10imagerow(imgnumimagecol-1)//imagecol imgallwidthf0im.size[0]*imagecolblockspace*(imagecol-1)imgallheightf0im.size[1]*imagerowblockspace*(imagerow-1)printf(imgallwidth,imgallheight)#------------------------------------------------------------imgallImage.new(modeRGB,size(imgallwidth,imgallheight),color(255,255,255))foriinrange(imagerow):forjinrange(imagecol):imgidi*imagecoljifimgidimgnum:breakfnameos.path.join(imgdir,%d.%s%(imgid,fext))fimImage.open(fname)xj*(f0im.size[0]blockspace)yi*(f0im.size[1]blockspace)imgall.paste(fim,(x,y))#------------------------------------------------------------outfilerd:\temp\imgall.jpgiflen(sys.argv)2:outfilerd:\temp\%s.jpg%sys.argv[2]imgall.save(outfile)#------------------------------------------------------------printf(\a)#------------------------------------------------------------# END OF FILE : IMGALL.PY#