Open source CBIR with SIFT or Harris-Laplace descriptors? - sift

Does anyone know a open source CBIR that use SIFT or Harris-Laplace descriptors?

Related

When will the file descriptor be allocated to a file?

I have searched it through some technology blogs, Google, Wikipedia and even Youtube Video Tutorial, but I am still confused because it seems contrary to what my teacher asked me to do.
1.When will the file descriptors be allocated to a file, after the file is open or created?
2.If the file descriptors are allocated after the file is open, can I use the function like open(int fileDescriptors, int mode) to open the file? How? (Cause this is what my teacher asked me to do). If I cannot, maybe the teacher is wrong.
I hope my questions are clear.
First of all, "file descriptors" as you are talking about them are a eunuchs concept that does not exist in all operating systems.
The exact operating differs among variants. At the risk over overgeneralization, each process has a number of file descriptors (512 and 1024 are common values). Generally most of these descriptors sit unused. The descriptor has to be mapped to a file in order to be used.
1.When will the file descriptors be allocated to a file, after the file is open or created?
Creating a file opens the file. Descriptors are mapped when a file is opened.
2.If the file descriptors are allocated after the file is open, can I use the function like open(int fileDescriptors, int mode) to open the file?
The file descriptors exist before the file is opened. Opening maps the file to a descriptor.

How does the "r+" mode to fopen work [duplicate]

I am reading some C text at the address: https://cs.senecac.on.ca/~btp100/pages/content/files.html
in the section "OPENING A FILE", the author wrote:
""r+" - opens the file for reading and possibly writing".
I dont understand why the author said "possibly writing". Why not "reading and writing". are there some cases we cannot write to file if using "r+"?
It's poor wording. It should be:
r+
Open file for update (reading and writing).
When you open a file with "r+" then the file is open for reading and writing BUT the file must exist first. If you open it with "w" then the file will be created so it does not need to exist. Hope that helps.
Of course, there are some writing into a file which can fail (think of a "disk is full" situation).
The "possible writing" phrase means just that a FILE* handle fopen-ed with "r+" might be used without any write operations. For instance, if your application want to overwrite some part of the file only under some circumstances, it can avoid the writing.

'File is corrupted' when opening docx file when created in C

I am using "UNIX" (on my virtual machine) and generating ".docx" file there using "C", after getting the file into Windows, when I am opening the file it's saying "the file is corrupted, can't be opened" and then its not opening.
I am using MS-Word 2010.
Here is the piece of code I am using:-
Write_to_file(){
FILE *fp;
if((fp=fopen("hello.docx","w"))==(FILE*)NULL){
printf("Error opening file");
return 0;
}
fprintf(fp,"Hello World");
fclose(fp);
}
Just with an extension name (doc docx) does not make the file a MS word file. Your code is only writing a text file. You can dectect this by file command under Linux.
Please reference this http://msdn.microsoft.com/en-us/library/cc313105(v=office.12).aspx, and write the REAL MS document file.
A doc file is not a simple text file. You'd want to use the txt format:
fopen("hello.txt", "w");
To actually read/write a doc file, you'd need to use a library designed specifically to read them and write them.
The spec for MS-DOC files is pretty lengthy, so I wouldn't implement my own reader/writer if I were you.

C Programming fopen() while opening a file

I've been wondering about this one. Most books I've read shows that when you open a file and you found that the file is not existing, you should put an error that there's no such file then exit the system...
FILE *stream = NULL;
stream = fopen("student.txt", "rt");
if (stream==NULL) {
printf(“Cannot open input file\n”);
exit(1);
else {printf("\nReading the student list directory. Wait a moment please...");
But I thought that instead of doing that.. why not automatically create a new one when you found that the file you are opening is not existing. Even if you will not be writing on the file upon using the program (but will use it next time). I'm not sure if this is efficient or not. I'm just new here and have no programming experience whatsoever so I'm asking your opinion what are the advantages and disadvantages of creating a file upon trying to open it instead of exiting the system as usually being exampled on the books.
FILE *stream = NULL;
stream = fopen("student.txt", "rt");
if (stream == NULL) stream = fopen("student.txt", "wt");
else {
printf("\nReading the student list directory. Wait a moment please...");
Your opinion will be highly appreciated. Thank you.
Because from your example, it seems like it's an input file, if it doesn't exist, no point creating it.
For example if the program is supposed to open a file, then count how many vowels in it, then I don't see much sense of creating the file if it doesn't exist.
my $0.02 worth.
Argument mode:
``r'' Open text file for reading.
``r+'' Open for reading and writing.
``w'' Truncate file to zero length or create text file for writing.
``w+'' Open for reading and writing. The file is created if it does not
exist, otherwise it is truncated.
``a'' Open for writing. The file is created if it does not exist.
``a+'' Open for reading and writing. The file is created if it does not
exist.
Your question is a simple case. Read above description, when you call fopen(), you should decide which mode shall be used. Please consider why a file is not created for "r" and "r+", and why a file is truncated for "w" and "w+", etc. All of these are reasonable designs.
If your program expects a file to exist and it doesn't, then creating one yourself doesn't make much sense, since it's going to be empty.
If OTOH, your program is OK with a file not existing and knows how to populate one from scratch, then it's perfectly fine to do so.
Either is fine as long as it makes sense for your program. Don't worry about efficiency here -- it's negligible. Worry about correctness first.
You may not have permission to create/write to a file in the directory that the user chooses. You will have to handle that error condition.

How can I tell if a file is open elsewhere in C on Linux?

How can I tell if a file is open in C? I think the more technical question would be how can I retrieve the number of references to a existing file and determine with that info if it is safe to open.
The idea I am implementing is a file queue. You dump some files, my code processes the files. I don't want to start processing until the producer closes the file descriptor.
Everything is being done in linux.
Thanks,
Chenz
Digging out that info is a lot of work(you'd have to search thorugh /proc/*/fd
You'd be better off with any of:
Save to temp then rename. Either write your files to a temporary filename or directory, when you're done writinh, rename it into the directory where your app reads them. Renaming is atomic, so when the file is present you know it's safe to read.
Maybe a variant of the above , when you're done writing the file foo you create an empty file named foo.finished. You look for the presence of *.finished when processing files.
Lock the files while writing, that way reading the file will just block until the writer unlocks it. See the flock/lockf functions, they're advisory locks though so both the reader and writer have to lock , and honor the locks.
I don't think there is any way to do this in pure C (it wouldn't be cross platform).
If you know what files you are using ahead of time, you can use inotify to be notified when they open.
Use the lsof command. (List Open Files).
C has facilities for handling files, but not much for getting information on them. In portable C, about the only thing you can do is try to open the file in the desired way and see if it works.
generally you can't do that for variuos reasons (e.g. you cannot say if the file is opened with another user).
If you can control the processes that open the file and you are try to avoid collisions by locking the file (there are many libraries on linux in order do that)
If you are in control of both producer and consumer, you could use lockf() of flock() to lock the file.
there is lsof command on most distros, which shows all currently open files, you can ofcourse grep its output if your files are in the same directory or have some recognizable name pattern.

Resources