Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Mode C even after merging #33 doesn't seem to work as given in documentation #50

Closed
Abhijit-2592 opened this issue Aug 30, 2017 · 5 comments

Comments

@Abhijit-2592
Copy link
Contributor

Abhijit-2592 commented Aug 30, 2017

In reference to #33

The documentation says: mode=c - Go to next image in the collection (set via the dirlist).

But the code in fetch_image.cgi

elsif($mode eq "c") {
    opendir(DIR,$LM_HOME . "Images/$collection") || die("Cannot read collections");
    my @all_images = readdir(DIR);
    closedir(DIR);

    my $c = 0;
    foreach my $i (@all_images) {
	if($i eq $image) {
	    goto next_section;
	}
	$c = $c+1;
    }
  next_section:
    if($c == scalar(@all_images)-1) {
	$c = 1;
    }
    $im_file = $all_images[$c+1];
    $im_dir = $folder;

Doesn't seem to read the foo.txt file which is created using populate_dirlist.sh

From my guess the code for mode = "c" should be similar to code for mode = "i" with the random part removed.

So, I think the code for mode = "c" should loook something like this:

if($mode eq "c") {
    my $fname = $LM_HOME . "annotationCache/DirLists/$collection.txt";
    
    if(!open(FP,$fname)) {
	print "Status: 404\n\n";
	return;
    }
    
    open(NUMLINES,"wc -l $fname |");
    my $numlines = <NUMLINES>;
    ($numlines,my $bar) = split(" DirLists",$numlines);
    close(NUMLINES);
    
    my $line = int(rand($numlines))+1; # this should be in series and not a random integer. 
    
    for(my $i=1; $i < $line; $i++) {
	my $garbage = readline(FP);
    }
    
    my $fileinfo = readline(FP);
    ($im_dir,$im_file) = split(",",$fileinfo);
    $im_file =~ tr/"\n"//d; # remove trailing newline
    
    close(FP);

@brianabrams could you please look at this?
Basically what I feel is, It should read the foo.txt file created by populate_dirlist.sh and display the images in order given in the text file

@Abhijit-2592
Copy link
Contributor Author

I have created a pull request which corrects mode = 'c' #51

@furick1
Copy link

furick1 commented Sep 17, 2017

Thanks Abhijit. I tested out your update and it worked for me. I also found that if you use a sort command at the end of the populate_dirlist.sh script that collections then match the ordering of the natural directory structure thus making use of mode=c more logical. Add "sort $HOMEDIRLIST/$dirlist -o $HOMEDIRLIST/$dirlist" at the end of the script for an improvement.

@Abhijit-2592
Copy link
Contributor Author

Glad it works 😁

@Abhijit-2592
Copy link
Contributor Author

That's a nice idea. Anyway, I don't use populate_dirlist.sh. I have my own python code which generates the text file which splits the work across multiple labelers (coz labeling is a daunting task😅). Anyway, I have already implemented your idea in that script.

@Abhijit-2592
Copy link
Contributor Author

This is solved!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants