生成netcdf文件时出现分段错误(核心转储)

时间:2016-02-10 07:46:01

标签: python segmentation-fault netcdf sift

:::::::::::::::::::::::: SIFT_FEATURE Method ::::::::::::::::::::::::: :::::::::::::

def sift_features(文件名,输入):

img = cv2.imread(filename)
gray= cv2.cvtColor(img,cv2.COLOR_BGR2GRAY)
sift = cv2.SIFT(70)
kp = sift.detect(gray,None)
img=cv2.drawKeypoints(gray,kp)
cv2.imwrite(filename +'_sift_keypoints.jpg',img)

index = []
for point in kp:
    temp = (point.pt, point.size, point.angle, point.response, point.octave, point.class_id) 

    index.append(temp)

        counter=[]
    for val in index:
        for ele in val:
        counter.append(ele)

    inputs.append(counter)

return inputs

#::::::::::::::将每个文件传递给Sift_features()::::::::::::::::::::::::::::::::::::: ::::::::::::::::::::::::::::::::::

for lineFilename in lineFilenames:
#   print "LINE FILE NAME", lineFilename
    if not (options.labelsOnly):
            if options.features:
            print "FILE NAME ---------------------------------- :", lineFilename
                lineLength = sift_features(lineFilename, inputs)
        if options.wholeBoard:
            fileLength+= lineLength
        else:
            seqLengths.append(lineLength)

:::::::创建netcdf文件:::::::::::::::::

ncfile =netcdf_helpers.NetCDFFile(ncFilename, 'w')
if not (options.labelsOnly):
    netcdf_helpers.createNcDim(ncfile,'numSeqs',len(seqLengths))
    netcdf_helpers.createNcDim(ncfile,'numTimesteps',len(inputs))
    netcdf_helpers.createNcDim(ncfile,'inputPattSize',len(inputs[0]))
netcdf_helpers.createNcDim(ncfile,'numLabels',len(labels))
netcdf_helpers.createNcStrings(ncfile,'labels',labels,      ('numLabels','maxLabelLength'),'labels')
netcdf_helpers.createNcStrings(ncfile,'targetStrings',targetStrings,('numSeqs','maxTargStringLength'),'target strings')
if not (options.labelsOnly):
    netcdf_helpers.createNcStrings(ncfile,'seqTags',seqTags,('numSeqs','maxSeqTagLength'),'sequence tags')
    netcdf_helpers.createNcVar(ncfile,'seqLengths',seqLengths,'i',('numSeqs',),'sequence lengths')
    netcdf_helpers.createNcVar(ncfile,'inputs',inputs,'f',('numTimesteps','inputPattSize'),'input patterns')
print "writing data to", ncFilename
ncfile.close()

筛选特征指示图像和每个点的70个点

temp = (point.pt, point.size, point.angle, point.response, point.octave, point.class_id) 

计算。我想通过

将功能值传递给netcdf文件
netcdf_helpers.createNcVar(ncfile,'seqLengths',seqLengths,'i',('numSeqs',),'sequence lengths') 

语句。 seqLengths变量具有所有图像的特征值。但是当我尝试生成netcdf文件时,它会遇到如下所述的错误。

creating netcdf dimension: numSeqs 1335574
creating netcdf dimension: numTimesteps 20
creating netcdf dimension: inputPattSize 210
creating netcdf dimension: numLabels 29
writing strings labels
creating netcdf dimension: maxLabelLength 6
creating netcdf variable labels
dimensions ('numLabels', 'maxLabelLength')
(29, 6)
writing strings targetStrings
creating netcdf dimension: maxTargStringLength 115
creating netcdf variable targetStrings
dimensions ('numSeqs', 'maxTargStringLength')
Segmentation fault (core dumped)

我知道seqLengths varriable将功能值传递给netcdf文件时发生错误。特征值的形式为[[(1,2,4,5),(6,7,8,9,10),(11,12,13,14,15)],[(16,17, 8,19,20),(21,22,23,24,25)]]

在这方面的任何帮助都将受到高度赞赏:)

0 个答案:

没有答案