My guess the problem is 

(define imleftname
  #"./tsukubaleft.jpg")

You're using a relative path to the jpg file which may be valid wherever 
your script file is located but DrRacket is probably starting up with a 
different working directory and the relative path is not resolving 
successfully.

I would suggest trying using `define-runtime-path` which deals with that 
kind of issue. It will automatically create the correct fully resolved path 
when you give it a relative path.

For example, do it like this:

(define-runtime-path imleftname "./tsukubaleft.jpg")


On Tuesday, April 10, 2018 at 4:38:12 AM UTC-4, Frédéric Morain-Nicolier 
wrote:
>
> Hello,
>
> I'm just a beginner in Racket and want to use the opencv bindings. I have 
> this small basic code :
>
> #! /usr/bin/env racket
> #lang racket/base
>
> (require
>   opencv/highgui)
>
> ; lecture des deux images et affichage (pour tester)
>
> (define imleftname
>   #"./tsukubaleft.jpg")
>
> (define im-left (imread imleftname CV_LOAD_IMAGE_COLOR))
> (imshow "Display window" im-left)
> (define key (cvWaitKey 0))
> (exit 0)
>
> The execution from the shell is ok  but when executing it in the DrRacket 
> console I get this error on (imread imleftname CV_LOAD_IMAGE_COLOR) :
>
> ptr-ref: contract violation
>   expected: (and/c cpointer? (not/c (lambda (p) (pointer-equal? p #f))))
>   given: #f
>   argument position: 1st
>   other arguments...:
>    #<ctype>
>
> Thanks for your help in advance to understand,
> Frédéric
>
>
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Racket Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to racket-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to