I am using PyCalland @pyimport cv2 to implement an OpenCV feature-matching program in Julia.
I have an example of the code I want to use in Python (see Brute-Force Matching with SIFT Descriptors and Ratio Test in this link: http://docs.opencv.org/3.0-beta/doc/py_tutorials/py_feature2d/py_matcher/py_matcher.html for the full Python code.)
Everything up to the point of drawMatchesKnn() works fine, but I have issues with the outImg argument when converting to Julia.
Documentation for drawMatchesKnn() is pasted below:
(and can also be found here:
http://docs.opencv.org/3.0-beta/modules/features2d/doc/drawing_function_of_keypoints_and_matches.html#drawmatches
Python: cv2.drawMatchesKnn(img1, keypoints1, img2, keypoints2, matches1to2[, outImg[, matchColor[, singlePointColor[, matchesMask[, flags]]]]]) → outImg
Parameter description:
As you can see from the sample program, the drawMatchesKnn() line in Python would look like this:img3 = cv2.drawMatchesKnn(train,kp1,query,kp2,good,None,flags=2) (the key argument is argument 6, specified as "None")
I'm having problems because I don't really know what an equivalent, working example in Julia would be.
I tried this:img3 = cv2.drawMatchesKnn(train,kp1,query,kp2,good)
And got this error: (so arg6 is required)
LoadError: PyError (:PyObject_Call) <type 'exceptions.TypeError'>
TypeError("Required argument 'outImg' (pos 6) not found",)
This: (passing the scalar value 0, which worked for the method drawKeyPoints() in another program)img3 = cv2.drawMatchesKnn(train,kp1,query,kp2,good,0,flags=2)
and got this error:
LoadError: PyError (:PyObject_Call) <type 'exceptions.SystemError'>
SystemError('NULL result without error in PyObject_Call',)
and this:img3 = cv2.drawMatchesKnn(train,kp1,query,kp2,good,nothing,flags=2)
and got this error:
LoadError: PyError (:PyObject_Call) <type 'exceptions.SystemError'>
SystemError('NULL result without error in PyObject_Call',)
Seems tricky to me because None in Python and nothing in Julia do not appear to behave the same way.
Anything else I could try? What could the problem be, and how can I fix it?
Thanks for reading!
Any help is much appreciated.
img3 = cv2.drawMatchesKnn(train,kp1,query,kp2, good, :none, flags=4)LoadError: PyError (:PyObject_Call) <type 'exceptions.SystemError'>
SystemError('NULL result without error in PyObject_Call',)
while loading In[60], in expression starting on line 22
in pyerr_check at /home/-/.julia/v0.5/PyCall/src/exception.jl:56 [inlined]
in pyerr_check at /home/-/.julia/v0.5/PyCall/src/exception.jl:61 [inlined]
in macro expansion at /home/-/.julia/v0.5/PyCall/src/exception.jl:81 [inlined]
in #pycall#46(::Array{Any,1}, ::Function, ::PyCall.PyObject, ::Type{PyCall.PyAny}, ::Array{UInt8,2}, ::Vararg{Any,N}) at /home/-/.julia/v0.5/PyCall/src/PyCall.jl:510
in (::PyCall.#kw##pycall)(::Array{Any,1}, ::PyCall.#pycall, ::PyCall.PyObject, ::Type{PyCall.PyAny}, ::Array{UInt8,2}, ::Vararg{Any,N}) at ./null:0
in #call#47(::Array{Any,1}, ::PyCall.PyObject, ::Array{UInt8,2}, ::Vararg{Any,N}) at /home/-/.julia/v0.5/PyCall/src/PyCall.jl:522
in (::PyCall.#kw#PyObject)(::Array{Any,1}, ::PyCall.PyObject, ::Array{UInt8,2}, ::Vararg{Any,N}) at ./null:0
in include_string(::String, ::String) at ./loading.jl:380
in eventloop(::ZMQ.Socket) at /home/-/.julia/v0.5/IJulia/src/IJulia.jl:143
in (::IJulia.##24#30)() at ./task.jl:310
good = []for m,n in matches: if m.distance < 0.75*n.distance: good.append([m])good = []for i=1:size(matches,1) if matches[i,1][:distance] < 0.75*matches[i,2][:distance] push!(good, matches[i,1]) endend