Forum: support


RE: nops_scan error [ Reply ] By: Achim Zeileis on 2025-10-14 02:38 | [forum:50109] |
Thanks for the follow-up! Indeed NOPS exams had been designed with A4 format in mind but we tried to adapt the scanning so that it also works when printed on letter paper. But I guess it depends on the details of the printing. Meanwhile I also had a look at improving the scanner heuristics. But I did not find a good and simple strategy that does not increase the risk of incorrectly determining the scanner markings (e.g., when students have scribbled in the margins). But at least the development version of the package here on R-Forge now throws a more intelligible error message. Thanks again for reporting this. |
RE: nops_scan error [ Reply ] By: Filipe Alberto on 2025-10-13 00:20 | [forum:50108] |
Yes, that worked. You are correct, I haven't printed anything yet, just testing this cool package. I think what happened is that I had my printer set for US letter. Once I changed it to A4, the margins became smaller, and the scan was successful. |
RE: nops_scan error [ Reply ] By: Achim Zeileis on 2025-10-12 23:26 | [forum:50107] |
Filipe, the problem is that the white margins are too large and nops_scan() does not find the scanner markings. We should definitely improve the error message for this and could potentially also improve the search heuristics to avoid the problem. I'll try to have a look whether this is possible. If your exam hasn't taken place, yet (as I guess from the image you provide), then I would recommend to print the exam sheets with smaller margins. This is why in the exams2nops tutorial (https://www.R-exams.org/tutorials/exams2nops/) we say: It is recommended not to scale the printout (i.e., without "Fit to printable area"). If you have already conducted the exam (or at least printed the exam sheets), then you can crop the PNG files prior to scanning using the R package "magick": library("magick") "S0000001.PNG" |> image_read() |> image_crop("2210x2860+170+220") |> image_write("T0000001.PNG") And then scanning the trimmed file T0000001.PNG works: exams::nops_scan("T0000001.PNG", file = FALSE) Reading PNG files: T0000001.PNG: Trimming PNG, rotating PNG, extracting information, done. [1] "T0000001.PNG 25102300001 00 030 0 1234567 10000 01000 01000 01000 10000 01000 10000 00010 01000 01000 00100 00000 00010 01100 10010 01000 10000 01000 00100 01000 00010 00010 00010 00100 01000 01000 10000 01000 10000 01000 00000 00000 00000 00000 00000 00000 00000 00000 00000 00000 00000 00000 00000 00000 00000" How I came up with the code for trimming the image: - Your PNG is 2550 x 3300 pixes and I wanted to trim 10-15% around the margins. - Hence I picked 4/30 = 13.3333% here because this gives nice integers and corresponds to 340x440 pixels to trim. - The resulting geometry is then 2210 x 2860 pixels and starts at pixel 170x220 of the original image. |
nops_scan error [ Reply ] By: Filipe Alberto on 2025-10-12 20:56 | [forum:50106]![]() |
I am getting this error when running nops_scan > nops_scan(dir = "scans") Splitting PDF files, done. S0000001.pdf: Converting PDF to PNG. S0000002.pdf: Converting PDF to PNG. Reading PNG files: S0000001.PNG: Trimming PNG Error in x[seq(round(rb * d[1L]), d[1L]), seq(1, round(0.17 * d[2L]))] : only 0's may be mixed with negative subscripts , ERRORS0000002.PNG: Trimming PNGError in x[seq(round(rb * d[1L]), d[1L]), seq(1, round(0.17 * d[2L]))] : only 0's may be mixed with negative subscripts , ERROR Creating ZIP file: adding: Daten.txt (deflated 39%) adding: S0000001.PNG (deflated 11%) adding: S0000002.PNG (deflated 6%) Warning message: In nops_scan(dir = "scans") : errors in scanned data, please run nops_fix() on 'nops_scan_20251012153533.zip' prior to nops_eval() The resulting zip file contains the daten.txt file with the following information S0000001.PNG ERROR S0000002.PNG ERROR The png files, converted from the pdf are there and look good (to me) see attached. Any thoughts on what the problem is? |