用Python编程计算机视觉第7章

2024-06-23 19:27:59 发布

您现在位置:Python中文网/ 问答频道 /正文

我正在看扬·埃里克·索莱姆写的书

我对第7章有点困惑,关于将图像添加到SQLite数据集中

在“add\ to\ index”方法中

imwords是一个直方图列表

imwords = self.voc.project(descr)

下面的代码让我很困惑:

word = imwords[i]
#wordid is the word number itself
self.con.execute("insert into imwords(imid,wordid,vocname) values (?,?,?)", (imid,word,self.voc.name)

这让我很困惑,因为imwords[i]只会给出单词在词汇表中的频率,而不会指明是哪个单词

因此,我在想,如果我们想添加一个图像所具有的词语,它是否应该像它一样:

word = imwords[i]
if word > 0:
    self.con.execute("insert into imwords(imid,wordid,vocname) values (?,?,?)", (imid,i,self.voc.name))

注意,我在sql语句中用i替换了word


Tags: name图像selfexecutevoc单词conword

热门问题