Hi,
I have a question about how to find a function in the opencv library.
I tried this:
(require :cffi)
;; load shared libs (cffi:load-foreign-library "libcv.so") (cffi:load-foreign-library "libhighgui.so")
;; define the function call CvCapture* capture = cvCaptureFromCAM( -1 ); (cffi:defctype cvcapture :pointer) (cffi:defcfun "cvCaptureFromCAM" cvcapture (type :int))
But I get: STYLE-WARNING: Undefined alien: "cvCaptureFromCAM"
Which means that "cffi" cannot find the name in the shared object file.
My shared object file looks like this:
nm /usr/lib64/libhighgui.so | grep -i cvcapturefromcam 000000000023d180 b _ZZL21icvCaptureFromCAM_V4LiE9autoindex
nm /usr/lib64/libhighgui.so | grep -i cvcapturecam 0000000000021760 t _ZL15icvCloseCAM_V4LP16CvCaptureCAM_V4L 0000000000021fa0 t _ZL15icvSetVideoSizeP16CvCaptureCAM_V4Lii 00000000000225f0 t _ZL19icvGrabFrameCAM_V4LP16CvCaptureCAM_V4L 00000000000216a0 t _ZL33v4l2_scan_controls_enumerate_menuP16CvCaptureCAM_V4L 0000000000021940 T _ZN20CvCaptureCAM_V4L_CPP11getPropertyEi 00000000000221c0 T _ZN20CvCaptureCAM_V4L_CPP11setPropertyEid 0000000000021d60 T _ZN20CvCaptureCAM_V4L_CPP13retrieveFrameEi 0000000000022a10 T _ZN20CvCaptureCAM_V4L_CPP4openEi 0000000000021880 T _ZN20CvCaptureCAM_V4L_CPP5closeEv 00000000000229f0 T _ZN20CvCaptureCAM_V4L_CPP9grabFrameEv 00000000000218b0 W _ZN20CvCaptureCAM_V4L_CPPD0Ev 0000000000021900 W _ZN20CvCaptureCAM_V4L_CPPD1Ev 000000000023af40 V _ZTI20CvCaptureCAM_V4L_CPP 0000000000033c20 V _ZTS20CvCaptureCAM_V4L_CPP 000000000023aee0 V _ZTV20CvCaptureCAM_V4L_CPP 000000000023d174 b _ZZL21icvSetPropertyCAM_V4LP16CvCaptureCAM_V4LidE5width 000000000023d170 b _ZZL21icvSetPropertyCAM_V4LP16CvCaptureCAM_V4LidE6height
Questions: 1) Am I doing it all wrong or can one do like this? 2) Is there a smart way to use the .so file to get the correct name of functions?
Hi -
not really knowing libcv but just staring at the nm output:
There are CvCaptureCAM functions bjt no cvCaptureFromCAM in the library ...
Cheers Frank
Am 30.06.2010 um 18:37 schrieb N J:
Hi,
I have a question about how to find a function in the opencv library.
I tried this:
(require :cffi)
;; load shared libs (cffi:load-foreign-library "libcv.so") (cffi:load-foreign-library "libhighgui.so")
;; define the function call CvCapture* capture = cvCaptureFromCAM( -1 ); (cffi:defctype cvcapture :pointer) (cffi:defcfun "cvCaptureFromCAM" cvcapture (type :int))
But I get: STYLE-WARNING: Undefined alien: "cvCaptureFromCAM"
Which means that "cffi" cannot find the name in the shared object file.
My shared object file looks like this:
nm /usr/lib64/libhighgui.so | grep -i cvcapturefromcam 000000000023d180 b _ZZL21icvCaptureFromCAM_V4LiE9autoindex
nm /usr/lib64/libhighgui.so | grep -i cvcapturecam 0000000000021760 t _ZL15icvCloseCAM_V4LP16CvCaptureCAM_V4L 0000000000021fa0 t _ZL15icvSetVideoSizeP16CvCaptureCAM_V4Lii 00000000000225f0 t _ZL19icvGrabFrameCAM_V4LP16CvCaptureCAM_V4L 00000000000216a0 t _ZL33v4l2_scan_controls_enumerate_menuP16CvCaptureCAM_V4L 0000000000021940 T _ZN20CvCaptureCAM_V4L_CPP11getPropertyEi 00000000000221c0 T _ZN20CvCaptureCAM_V4L_CPP11setPropertyEid 0000000000021d60 T _ZN20CvCaptureCAM_V4L_CPP13retrieveFrameEi 0000000000022a10 T _ZN20CvCaptureCAM_V4L_CPP4openEi 0000000000021880 T _ZN20CvCaptureCAM_V4L_CPP5closeEv 00000000000229f0 T _ZN20CvCaptureCAM_V4L_CPP9grabFrameEv 00000000000218b0 W _ZN20CvCaptureCAM_V4L_CPPD0Ev 0000000000021900 W _ZN20CvCaptureCAM_V4L_CPPD1Ev 000000000023af40 V _ZTI20CvCaptureCAM_V4L_CPP 0000000000033c20 V _ZTS20CvCaptureCAM_V4L_CPP 000000000023aee0 V _ZTV20CvCaptureCAM_V4L_CPP 000000000023d174 b _ZZL21icvSetPropertyCAM_V4LP16CvCaptureCAM_V4LidE5width 000000000023d170 b _ZZL21icvSetPropertyCAM_V4LP16CvCaptureCAM_V4LidE6height
Questions:
- Am I doing it all wrong or can one do like this?
- Is there a smart way to use the .so file to get the correct name of
functions?
cffi-devel mailing list cffi-devel@common-lisp.net http://common-lisp.net/cgi-bin/mailman/listinfo/cffi-devel
Thanks for the quick help.
I think I got some insight into the problem. Frank is right, there is no cvCaputerFromCam anymore in the API. And as Stelian noted, one probably need to acount for the differences between C and C++.
However,, I finally extracted a nice list of the functions available with objdump /usr/lib64/libhighgui.so -t | gawk '{ print $6 }' | grep -v _Z | sort | grep cv | grep -v cpp
cvConvertImage cvCreateCameraCapture cvCreateFileCapture cvCreateTrackbar cvCreateTrackbar2 cvCreateVideoWriter cvDecodeImage cvDecodeImageM cvDestroyAllWindows cvDestroyWindow cvEncodeImage cvGetCaptureDomain cvGetCaptureProperty cvGetTrackbarPos cvGetWindowHandle cvGetWindowName cvGrabFrame cvHaveImageReader cvHaveImageWriter cvInitSystem cvLoadImage cvLoadImageM cvMoveWindow cvNamedWindow cvQueryFrame cvReleaseCapture cvReleaseVideoWriter cvResizeWindow cvRetrieveFrame cvSaveImage cvSetCaptureProperty cvSetMouseCallback cvSetTrackbarPos cvShowImage cvStartWindowThread cvTopLevelWidget cvWaitKey cvWriteFrame
However, thanks for the quick help.
Best regards, Nik
On Wed, Jun 30, 2010 at 7:11 PM, Frank Goenninger frgo@me.com wrote:
Hi -
not really knowing libcv but just staring at the nm output:
There are CvCaptureCAM functions bjt no cvCaptureFromCAM in the library ...
Cheers Frank
Am 30.06.2010 um 18:37 schrieb N J:
Hi,
I have a question about how to find a function in the opencv library.
I tried this:
(require :cffi)
;; load shared libs (cffi:load-foreign-library "libcv.so") (cffi:load-foreign-library "libhighgui.so")
;; define the function call CvCapture* capture = cvCaptureFromCAM( -1 ); (cffi:defctype cvcapture :pointer) (cffi:defcfun "cvCaptureFromCAM" cvcapture (type :int))
But I get: STYLE-WARNING: Undefined alien: "cvCaptureFromCAM"
Which means that "cffi" cannot find the name in the shared object file.
My shared object file looks like this:
nm /usr/lib64/libhighgui.so | grep -i cvcapturefromcam 000000000023d180 b _ZZL21icvCaptureFromCAM_V4LiE9autoindex
nm /usr/lib64/libhighgui.so | grep -i cvcapturecam 0000000000021760 t _ZL15icvCloseCAM_V4LP16CvCaptureCAM_V4L 0000000000021fa0 t _ZL15icvSetVideoSizeP16CvCaptureCAM_V4Lii 00000000000225f0 t _ZL19icvGrabFrameCAM_V4LP16CvCaptureCAM_V4L 00000000000216a0 t _ZL33v4l2_scan_controls_enumerate_menuP16CvCaptureCAM_V4L 0000000000021940 T _ZN20CvCaptureCAM_V4L_CPP11getPropertyEi 00000000000221c0 T _ZN20CvCaptureCAM_V4L_CPP11setPropertyEid 0000000000021d60 T _ZN20CvCaptureCAM_V4L_CPP13retrieveFrameEi 0000000000022a10 T _ZN20CvCaptureCAM_V4L_CPP4openEi 0000000000021880 T _ZN20CvCaptureCAM_V4L_CPP5closeEv 00000000000229f0 T _ZN20CvCaptureCAM_V4L_CPP9grabFrameEv 00000000000218b0 W _ZN20CvCaptureCAM_V4L_CPPD0Ev 0000000000021900 W _ZN20CvCaptureCAM_V4L_CPPD1Ev 000000000023af40 V _ZTI20CvCaptureCAM_V4L_CPP 0000000000033c20 V _ZTS20CvCaptureCAM_V4L_CPP 000000000023aee0 V _ZTV20CvCaptureCAM_V4L_CPP 000000000023d174 b _ZZL21icvSetPropertyCAM_V4LP16CvCaptureCAM_V4LidE5width 000000000023d170 b _ZZL21icvSetPropertyCAM_V4LP16CvCaptureCAM_V4LidE6height
Questions:
- Am I doing it all wrong or can one do like this?
- Is there a smart way to use the .so file to get the correct name of
functions?
cffi-devel mailing list cffi-devel@common-lisp.net http://common-lisp.net/cgi-bin/mailman/listinfo/cffi-devel
On Wed, 2010-06-30 at 18:37 +0200, N J wrote:
Hi,
I have a question about how to find a function in the opencv library.
I tried this:
(require :cffi)
;; load shared libs (cffi:load-foreign-library "libcv.so") (cffi:load-foreign-library "libhighgui.so")
;; define the function call CvCapture* capture = cvCaptureFromCAM( -1 ); (cffi:defctype cvcapture :pointer) (cffi:defcfun "cvCaptureFromCAM" cvcapture (type :int))
But I get: STYLE-WARNING: Undefined alien: "cvCaptureFromCAM"
Which means that "cffi" cannot find the name in the shared object file.
My shared object file looks like this:
nm /usr/lib64/libhighgui.so | grep -i cvcapturefromcam 000000000023d180 b _ZZL21icvCaptureFromCAM_V4LiE9autoindex
nm /usr/lib64/libhighgui.so | grep -i cvcapturecam 0000000000021760 t _ZL15icvCloseCAM_V4LP16CvCaptureCAM_V4L 0000000000021fa0 t _ZL15icvSetVideoSizeP16CvCaptureCAM_V4Lii 00000000000225f0 t _ZL19icvGrabFrameCAM_V4LP16CvCaptureCAM_V4L 00000000000216a0 t _ZL33v4l2_scan_controls_enumerate_menuP16CvCaptureCAM_V4L 0000000000021940 T _ZN20CvCaptureCAM_V4L_CPP11getPropertyEi 00000000000221c0 T _ZN20CvCaptureCAM_V4L_CPP11setPropertyEid 0000000000021d60 T _ZN20CvCaptureCAM_V4L_CPP13retrieveFrameEi 0000000000022a10 T _ZN20CvCaptureCAM_V4L_CPP4openEi 0000000000021880 T _ZN20CvCaptureCAM_V4L_CPP5closeEv 00000000000229f0 T _ZN20CvCaptureCAM_V4L_CPP9grabFrameEv 00000000000218b0 W _ZN20CvCaptureCAM_V4L_CPPD0Ev 0000000000021900 W _ZN20CvCaptureCAM_V4L_CPPD1Ev 000000000023af40 V _ZTI20CvCaptureCAM_V4L_CPP 0000000000033c20 V _ZTS20CvCaptureCAM_V4L_CPP 000000000023aee0 V _ZTV20CvCaptureCAM_V4L_CPP 000000000023d174 b _ZZL21icvSetPropertyCAM_V4LP16CvCaptureCAM_V4LidE5width 000000000023d170 b _ZZL21icvSetPropertyCAM_V4LP16CvCaptureCAM_V4LidE6height
Questions:
- Am I doing it all wrong or can one do like this?
- Is there a smart way to use the .so file to get the correct name of
functions?
That library seems to be C++ or a C library compiled with the C++ compiler and it doesn't export functions with C linkage, so you need to make one yourself
On Thu, 1 Jul 2010, Stelian Ionescu wrote:
Questions:
- Am I doing it all wrong or can one do like this?
- Is there a smart way to use the .so file to get the correct name of
functions?
That library seems to be C++ or a C library compiled with the C++ compiler and it doesn't export functions with C linkage, so you need to make one yourself
2) You can use nm. Even better are object files with dwarf2 debug info... They tell you just about everything imaginable. Much better than grovelling sources or headers. http://reality.sgiweb.org/davea/dwarf.html
FYI, here's everything you want to know about C++ calling conventions (hint: they can often be used without a C wrapper). http://www.agner.org/optimize/calling_conventions.pdf
- Daniel
On Thu, 2010-07-01 at 01:11 -0400, Daniel Herring wrote:
On Thu, 1 Jul 2010, Stelian Ionescu wrote:
Questions:
- Am I doing it all wrong or can one do like this?
- Is there a smart way to use the .so file to get the correct name of
functions?
That library seems to be C++ or a C library compiled with the C++ compiler and it doesn't export functions with C linkage, so you need to make one yourself
- You can use nm. Even better are object files with dwarf2 debug info...
They tell you just about everything imaginable. Much better than grovelling sources or headers. http://reality.sgiweb.org/davea/dwarf.html
Groveling the headers serves two purposes: dealing with CPP macros, i.e. finding the value of constant macros or wrapping in a function those that expand to code; and finding the layout and size of structs Is DWARF information of any use in the aforementioned cases ?