fprintf(stderr, "shmat failed\n");
exit(EXIT_FAILURE);
}
printf("Memory attached at %X\n", (int)shared_memory);
shared_stuff = (struct shared_use_st *)shared_memory;
while(running) {
while(shared_stuff->written_by_you == 1) {
sleep(1);
printf("waiting for client.\n");
}
printf("Enter some text: ");
fgets(buffer, BUFSIZ, stdin);
strncpy(shared_stuff->some_text, buffer, TEXT_SZ);
shared_stuff->written_by_you = 1;
if (strncmp(buffer, "end", 3) == 0) {
running = 0;
}
}
if (shmdt(shared_memory) == -1) {
fprintf(stderr, "shmdt failed\n");
exit(EXIT_FAILURE);
}
exit(EXIT_SUCCESS);
}
SHM算法复杂度分析:
SHM算法充分利用了图像库语义辞典中的语义层级结构和语义分类标签信息,实现了逐步求精的图像语义相似性匹配。在最优情况下,只需计算两幅图在一个语义层级上的距离,它的复杂度为O(n);在最坏情况下,需要遍历所有语义层级并计算相似性距离,它的复杂度为O(n*n),就是算法的复杂度与语义辞典中语义分类项目的数目成比例,从而使得基于图像语义的图像检索结果更加符合人对于语义信息逐层近似的认知能力,比较有使用前景。
考虑检索词义多样性的图像检索系统设计(3):http://www.youerw.com/jisuanji/lunwen_20509.html