Page 30 of 60
Re: PureBasic Interface to OpenCV
Posted: Mon Jun 08, 2015 11:25 pm
by bbanelli
JHPJHP wrote:I'm not currently releasing "PureBasic Interface to OpenCV 3.0" due to the following issues:
- function: cvCreateCameraCapture
-- either the option window opens with no options and cannot connect the webcam, or the webcam light indicates a connection, but a black screen is displayed
Can you tell why isn't cvCaptureFromCAM() available in libraries; should there be any difference anyway?
Re: PureBasic Interface to OpenCV
Posted: Mon Jun 08, 2015 11:39 pm
by JHPJHP
Hi bbanelli,
cvCreateCameraCapture is the original C function from before OpenCV 2.1. With the transition to C++ cv.CaptureFromCAM was added. This was later replaced with cv2.VideoCapture.
- through the C interface we only have access to: cvCreateCameraCapture
The following declaration is included in the videoio_c.h (header) file.
#define cvCaptureFromCAM cvCreateCameraCapture
I believe the current issue with the function cvCreateCameraCapture is due to the way the "opencv_world300" binaries were built; missing vital options.
Because my questions weren't well received by the OpenCV community, I tried emailing their admin department directly. After five unanswered emails the alternatives are:
- wait for a new release of OpenCV 3.0 +
- rebuild the binaries trying various options
- solve the problem (already spent a week of "trial and error")
- keep the interface at OpenCV 2.4.11
Re: PureBasic Interface to OpenCV
Posted: Tue Jun 09, 2015 8:22 am
by bbanelli
JHPJHP wrote:I believe the current issue with the function cvCreateCameraCapture is due to the way the "opencv_world300" binaries were built; missing vital options.
Because my questions weren't well received by the OpenCV community, I tried emailing their admin department directly. After five unanswered emails the alternatives are:
- wait for a new release of OpenCV 3.0 +
- rebuild the binaries trying various options
- solve the problem (already spent a week of "trial and error")
- keep the interface at OpenCV 2.4.11
I've tried recompiling it several times and the best thing I've got were some artifacts on camera. Well, at least it was not completely dark.
I guess this is only C issue, since examples in C++ with camera work just fine...

Re: PureBasic Interface to OpenCV
Posted: Tue Jun 09, 2015 3:42 pm
by AAT
Hi, JHPJHP
JHPJHP wrote:
During my tests Windows 8 has never produced a black-screen using the binaries up to and including OpenCV 2.4.11, while OpenCV 3.0 binaries produce a black-screen in all operating systems.
Hmm..., it is strange. I built the example "cv_cam_saveimage.pb" from folder "Pending" with openCV3.0 and there are no problems in WindowsXP 32 bit.
There is a black screen in the Windows7 64 bit, regardless of the 32- or 64-bit version of PureBasic that I used to build exe.
So, i think the "black screen" problem is in the Windows 64.
Re: PureBasic Interface to OpenCV
Posted: Wed Jun 10, 2015 12:05 am
by JHPJHP
Hi bbanelli,
Thank you for testing the interface with rebuilt binaries, I thought for sure that an option was left unchecked when the default binaries were originally built.
Did you try with the following options: HAVE_VIDEOINPUT HAVE_DSHOW?
QUESTION: Why am I able to display pictures and play AVI files, but I'm not able to capture webcam images?
ANSWER: Recompile changing the "Preprocesser Definitions" in the C/C++ panel of the properties page to include: HAVE_VIDEOINPUT HAVE_DSHOW.
Your support is very much appreciated.
-------------------------------------------------------------
Hi AAT,
Thank you for the clarification that the webcam examples using the OpenCV 3.0 binaries are working in Windows XP 32 bit. I should have stated that my tests only included Windows 7, 8 64 bit.
(my Windows XP computer is not equipped with a webcam)
I took your lead and tested the example: cv_houghlines_2.pb in Windows XP, but it returned the same negative results.
Re: PureBasic Interface to OpenCV
Posted: Wed Jun 10, 2015 1:29 am
by bbanelli
JHPJHP wrote:Hi bbanelli,
Thank you for testing the interface with rebuilt binaries, I thought for sure that an option was left unchecked when the default binaries were originally built.
Did you try with the following options: HAVE_VIDEOINPUT HAVE_DSHOW?
QUESTION: Why am I able to display pictures and play AVI files, but I'm not able to capture webcam images?
ANSWER: Recompile changing the "Preprocesser Definitions" in the C/C++ panel of the properties page to include: HAVE_VIDEOINPUT HAVE_DSHOW.
Your support is very much appreciated.
It didn't help, except I kept getting this kind of warnings.
Code: Select all
11>D:\opencv-master\build\cvconfig.h(65): warning C4005: 'HAVE_DSHOW': macro redefinition (compiling source file ..\..\..\modules\core\src\alloc.cpp)
11> D:\opencv-master\build\cvconfig.h(65): note: command-line arguments: see previous definition of 'HAVE_DSHOW' (compiling source file ..\..\..\modules\core\src\alloc.cpp)
Perhaps I'll try rebuilding them without world module (so they would be separated DLL's such as ones in your v2.4 and try again (and modifying your PB files to get all imports).
Re: PureBasic Interface to OpenCV
Posted: Wed Jun 10, 2015 7:25 am
by JHPJHP
Hi bbanelli,
bbanelli wrote:Perhaps I'll try rebuilding them without world module (so they would be separated DLL's ...
If you have the time that would be great.
No need to modify the include-file:
cv_functions.pbi.
- I've taken care of that
Included in the download is a simple script I wrote to parse out the "Import Functions":
FormatFunctions.pb
- 1. choose the format file:
cv_functions.pbi (OpenCV 2.4.11)
- 2. choose the parse file:
cv_functions.pbi (OpenCV 3.0)
- 3. choose the location/filename to save the new include-file:
cv_functions.pbi
NB*: FormatFunctions.pb only parses the "Import Functions" to the correct libraries, everything else is done manually.
Re: PureBasic Interface to OpenCV
Posted: Wed Jun 10, 2015 8:45 am
by bbanelli
JHPJHP wrote:Hi bbanelli,
bbanelli wrote:Perhaps I'll try rebuilding them without world module (so they would be separated DLL's ...
If you have the time that would be great.
No need to modify the include-file:
cv_functions.pbi.
- I've taken care of that:
OpenCV 3.0 Functions
Included in the download is a simple script I wrote to parse out the "Import Functions":
FormatFunctions.pb
- 1. choose the format file:
cv_functions.pbi (OpenCV 2.4.11)
- 2. choose the parse file:
cv_functions.pbi (OpenCV 3.0)
- 3. choose the location/filename to save the new include-file:
cv_functions.pbi
NB*: FormatFunctions.pb only parses the "Import Functions" to the correct libraries, everything else is done manually.
Greetings JHPJHP,
I had to move some functions to opencv_videoio300.lib and opencv_imgcodecs300.lib since they are no longer in opencv_highgui300.lib, but regardless, effect is the same - no video.

Re: PureBasic Interface to OpenCV
Posted: Wed Jun 10, 2015 1:57 pm
by AAT
Hi!
AAT wrote:So, i think the "black screen" problem is in the Windows 64.
I was wrong, the program doesn't work in windows7 32bit too

Re: PureBasic Interface to OpenCV
Posted: Wed Jun 10, 2015 9:28 pm
by JHPJHP
Hi bbanelli,
Thank you for putting in the extra effort, I'm not sure what else can be done except wait for a new release and hope for the best.
------------------------------------------------------------
Hi AAT,
Thank you for the additional information.
------------------------------------------------------------
Since I wasn't getting anywhere asking for help from the OpenCV forum or by emailing their admin department, I decided to create a couple issue reports; feel free to add information.
- I purposely left the details vague to illicit a response, but maybe more information is better
--
cvCreateCameraCapture (Bug #4395) --
DONE
--
cvHoughLines2 (Bug #4396) --
CANCELLED
Re: PureBasic Interface to OpenCV
Posted: Sat Jun 13, 2015 10:32 am
by JHPJHP
Hi AAT, bbanelli,
I've figured out the issue with OpenCV 3.0 and
cvHoughLines2...
The Functions declaration has changed
(imgproc_c.h).
Code: Select all
OpenCV 2.4.11
- CVAPI(CvSeq*) cvHoughLines2( CvArr* image, void* line_storage, int method,
double rho, double theta, int threshold,
double param1 CV_DEFAULT(0), double param2 CV_DEFAULT(0));
OpenCV 3.0:
- CVAPI(CvSeq*) cvHoughLines2( CvArr* image, void* line_storage, int method,
double rho, double theta, int threshold,
double param1 CV_DEFAULT(0), double param2 CV_DEFAULT(0),
double min_theta CV_DEFAULT(0), double max_theta CV_DEFAULT(CV_PI));
I think I've also figured out the problem with the webcam examples...
While reviewing various header files and in the process of adding additional Constants, I came across the following information
(highgui_c.h):
/* start capturing frames from camera: index = camera_index + domain_offset (CV_CAP_*) */
cvGetCaptureDomain(*capture): Running this Function against the working webcam examples (OpenCV 2.4.11) the return value was 700. When I ran the same function against the non-working webcam examples (OpenCV 3.0) the return value was 200.
#CV_CAP_DSHOW = 700: I believe my previous assumption was correct, that the "world" binaries were built without the following options:
HAVE_VIDEOINPUT HAVE_DSHOW.
- if either of you could test this would be very much appreciated, as I'm not currently equipped with the required software
Re: PureBasic Interface to OpenCV
Posted: Sat Jun 13, 2015 1:52 pm
by AAT
Hi, JHPJHP
I tested the function
cvGetCaptureDomain(*capture), it return:
700, openCV2.4.11, Windows XP 32-bit
200, openCV3, Windows XP -32 bit, Windows 7 64-bit.
It is strange, but it's a fact: the example cv_cam_saveimage.pb, compiled with openCV3, is working now in the Windows XP
and in the Windows 7 64-bit (see my previous post
http://www.purebasic.fr/english/viewtop ... 20#p466220)
too.
Re: PureBasic Interface to OpenCV
Posted: Sat Jun 13, 2015 5:39 pm
by JHPJHP
Hi AAT,
This can be explained:
ATT wrote:I tested the function cvGetCaptureDomain(*capture), it return:
700, openCV2.4.11, Windows XP 32-bit
200, openCV3, Windows XP -32 bit, Windows 7 64-bit.
...
Take a look at the new Constants I've added, a return value of 200 means that the webcam is using "Video for Windows (#CV_CAP_VFW).
- some computers will work some of the time if VFW is supported and can access the webcam
I know from previous work that
VfW (Video for Windows) is not reliable in newer OS' especially 64bit versions. I believe by rebuilding the binaries with "DirectShow" (HAVE_VIDEOINPUT HAVE_DSHOW) the problem will be fixed.
Test this by forcing your webcam to use DirectShow (700):
- OpenCV 2.4.11:
connects, OpenCV 3.0:
fails
Code: Select all
*capture.CvCapture = cvCreateCameraCapture(#CV_CAP_DSHOW)
NB*: This was also the case in previous versions of OpenCV:
https://rafaelbarreto.wordpress.com/201 ... t-working/.
Re: PureBasic Interface to OpenCV
Posted: Sun Jun 14, 2015 11:23 am
by AAT
Hi JHPJHP,
JHPJHP wrote:Test this by forcing your webcam to use DirectShow (700):
Code: Select all
*capture.CvCapture = cvCreateCameraCapture(#CV_CAP_DSHOW)
I tested and got the same results.
OpenCV3 connects only with #CV_CAP_VFW.
Can anybody to rebuild binaries with DirectShow enabled?
Re: PureBasic Interface to OpenCV
Posted: Tue Jun 16, 2015 5:12 pm
by AAT
Hi
I got today new UVC web-camera module 1280*720 pix. It not connects with #CV_CAP_VFW, it connects only with #CV_CAP_DSHOW (Windows XP 32 bit, OpenCV2.4.11).