PureBasic Interface to OpenCV

Developed or developing a new product in PureBasic? Tell the world about it.
AAT
Enthusiast
Enthusiast
Posts: 259
Joined: Sun Jun 15, 2008 3:13 am
Location: Russia

Re: PureBasic Interface to OpenCV

Post by AAT »

Hi, JHPJHP!
Thank you for a great job!
I tried to build my program with openCV3: it is not working...
The problem with using h264 encoding in ffmpeg module is not resolved. :(
I think that I'm not going to use version 3 yet.

Good luck!
User avatar
JHPJHP
Addict
Addict
Posts: 2251
Joined: Sat Oct 09, 2010 3:47 am

Re: PureBasic Interface to OpenCV

Post by JHPJHP »

Hi AAT,

Thank you.

It's not easy to move forward when the OpenCV community has pretty much dropped their C support.
- I posted a question on their forum, and because it referenced the C interface it wasn't well received
- I also sent three emails with support questions, all unanswered

I've updated the original 32bit and 64bit downloads with various bug fixes.
- included: global find / replace modifying the Procedure CvMouseCallback (x / y parameters)
Last edited by JHPJHP on Thu Jun 04, 2015 7:12 pm, edited 3 times in total.

If you're not investing in yourself, you're falling behind.

My PureBasic StuffFREE STUFF, Scripts & Programs.
My PureBasic Forum ➤ Questions, Requests & Comments.
AAT
Enthusiast
Enthusiast
Posts: 259
Joined: Sun Jun 15, 2008 3:13 am
Location: Russia

Re: PureBasic Interface to OpenCV

Post by AAT »

Hi JHPJHP!

I downloaded your new pack, thanks.
I will try to build my program with opencv3 one more time.
User avatar
JHPJHP
Addict
Addict
Posts: 2251
Joined: Sat Oct 09, 2010 3:47 am

Re: PureBasic Interface to OpenCV

Post by JHPJHP »

Hi AAT,

OpenCV 3.0 Gold came out yesterday, so you may want to test your program using the new binaries.

I replaced the binaries from the OpenCV 3.0 test interface with the new ones, but the previous problems are still present.

I sent another couple emails to OpenCV admin (no response):
... I’ve tested OpenCV 3.0 Gold, and the following issues are still present:

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

function: cvHoughLines2 (option: CV_HOUGH_STANDARD)
- x86: CvSeq Structure: field [ total ] returns 0 (crashes the interface)
- x64: CvSeq Structure: field [ total ] returns 0
(option: CV_HOUGH_PROBABILISTIC returns the correct result for x86 / x64)

Can you please let me know if the legacy binaries will be included in a future release.
NB*: I've also applied a few small bug fixes to the existing downloads.
Last edited by JHPJHP on Sun Jun 07, 2015 1:32 am, edited 1 time in total.

If you're not investing in yourself, you're falling behind.

My PureBasic StuffFREE STUFF, Scripts & Programs.
My PureBasic Forum ➤ Questions, Requests & Comments.
chris319
Enthusiast
Enthusiast
Posts: 782
Joined: Mon Oct 24, 2005 1:05 pm

Re: PureBasic Interface to OpenCV

Post by chris319 »

I haven't had time to fool around with OpenCV lately. I've been trying to track down the source of color errors in compressed video, particularly the ffmpeg implementation of webm/VP8/VP9. That will likely be an uphill battle, so I may come back to OpenCV if the color work goes nowhere.

The link in the previous post returns a 401 error.
User avatar
JHPJHP
Addict
Addict
Posts: 2251
Joined: Sat Oct 09, 2010 3:47 am

Re: PureBasic Interface to OpenCV

Post by JHPJHP »

Hi chris319,

Sorry about the 401 error, I thought I could get away with a few quick updates...

With all the things I've tried to get "OpenCV 3.0 Gold" working with PureBasic, I've found and applied some basic bug fixes to the test package and the original downloads.

Cheers.

If you're not investing in yourself, you're falling behind.

My PureBasic StuffFREE STUFF, Scripts & Programs.
My PureBasic Forum ➤ Questions, Requests & Comments.
chris319
Enthusiast
Enthusiast
Posts: 782
Joined: Mon Oct 24, 2005 1:05 pm

Re: PureBasic Interface to OpenCV

Post by chris319 »

JHPJHP: I looked at the OpenCV library routine that you suggested to clip webcam video -- I believe it is called threshold. I saw nothing in it that would accomplish what I need, which is simply -- if sample > 254: sample = 254: elseif sample < 1: sample = 1.

Thank you for suggesting it, though.
User avatar
JHPJHP
Addict
Addict
Posts: 2251
Joined: Sat Oct 09, 2010 3:47 am

Re: PureBasic Interface to OpenCV

Post by JHPJHP »

Hi chris319,

Sorry - I may have misunderstood your requirements:
JHPJHP wrote:The following may be what you're looking for: cvCvtColor
- additional information

See the example: cv_cvtcolor.pb
- hit the spacebar until the heading reads "XYZ"
My response was in reference to Color Space Rec.709:
chris319 wrote:In high-end video, Rec.709 specifies that digital code 16 shall be reference black, with codes 1 to 15 acting as "footroom". Digital code 235 shall be reference white, with codes 236 to 254 acting as "headroom". Codes 0 and 255 are used as sync and are not allowed.
- cvtColor: Converts an image from one color space to another.
- cvMixChannels: Copies specified channels from input arrays to the specified channels of output arrays.

From the above links:
- RGB <--> CIE XYZ.Rec 709 with D65 white point ( CV_BGR2XYZ, CV_RGB2XYZ, CV_XYZ2BGR, CV_XYZ2RGB )
Last edited by JHPJHP on Sun Jun 07, 2015 1:33 am, edited 1 time in total.

If you're not investing in yourself, you're falling behind.

My PureBasic StuffFREE STUFF, Scripts & Programs.
My PureBasic Forum ➤ Questions, Requests & Comments.
chris319
Enthusiast
Enthusiast
Posts: 782
Joined: Mon Oct 24, 2005 1:05 pm

Re: PureBasic Interface to OpenCV

Post by chris319 »

Thanks, but I can convert the color space with PB code. I create a BT.709 "Y" signal from RGB in PB for my "scope" display.
User avatar
JHPJHP
Addict
Addict
Posts: 2251
Joined: Sat Oct 09, 2010 3:47 am

Re: PureBasic Interface to OpenCV

Post by JHPJHP »

Updated (x86 / x64):
- added Structures and Prototypes
-- updated all the camera examples with the CvCapture Structure
- updated the example: cv_overlay_1.pb
- updated all the pb_* examples, most notably: pb_cam_resolution.pb
-- fixed an issue with AAT's example: pb_cam_preferences.pb
(the example originally worked, but stopped working after I made some format changes)

NB*: Various other bug fixes have been applied to both interfaces.

If you're not investing in yourself, you're falling behind.

My PureBasic StuffFREE STUFF, Scripts & Programs.
My PureBasic Forum ➤ Questions, Requests & Comments.
AAT
Enthusiast
Enthusiast
Posts: 259
Joined: Sun Jun 15, 2008 3:13 am
Location: Russia

Re: PureBasic Interface to OpenCV

Post by AAT »

Hi, JHPJHP!
Thanks again!
Your last addition in structures... Where you found this one?
Is this addition actual for older versions opencv?
And does this addition correct "black screen" error in Windows 8?
User avatar
JHPJHP
Addict
Addict
Posts: 2251
Joined: Sat Oct 09, 2010 3:47 am

Re: PureBasic Interface to OpenCV

Post by JHPJHP »

Hi AAT,

The new Structures / Prototypes were declared using older documentation referencing the C interface, but the following quote is from the latest "OpenCV Reference Manual".
Note: In C API the black-box structure CvCapture is used instead of VideoCapture.
NB*: The CvCapture Structure does not have a public interface and is used only as a parameter for video capturing functions.

Webcam Examples
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.

*** I mistakenly left out the [ count.l ] field in the Structure declaration, it has now been corrected in both interfaces ***

Code: Select all

/***************************** CvCapture structure ******************************/

#define CV_CAPTURE_BASE_API_COUNT 6

typedef void         (CV_CDECL* CvCaptureCloseFunc)         ( CvCapture* capture );
typedef int          (CV_CDECL* CvCaptureGrabFrameFunc)     ( CvCapture* capture );
typedef IplImage   * (CV_CDECL* CvCaptureRetrieveFrameFunc) ( CvCapture* capture );
typedef double       (CV_CDECL* CvCaptureGetPropertyFunc)   ( CvCapture* capture, int id );
typedef int          (CV_CDECL* CvCaptureSetPropertyFunc)   ( CvCapture* capture,
                                                              int id, double value );
typedef const char * (CV_CDECL* CvCaptureGetDescriptionFunc)( CvCapture* capture );

typedef struct CvCaptureVTable
{
    int                           count;
    CvCaptureCloseFunc            close;
    CvCaptureGrabFrameFunc        grab_frame;
    CvCaptureRetrieveFrameFunc    retrieve_frame;
    CvCaptureGetPropertyFunc      get_property;
    CvCaptureSetPropertyFunc      set_property;
    CvCaptureGetDescriptionFunc   get_description;
}
CvCaptureVTable;

typedef struct CvCapture
{
    CvCaptureVTable* vtable;
}
CvCapture;
Last edited by JHPJHP on Tue Jun 09, 2015 1:05 am, edited 3 times in total.

If you're not investing in yourself, you're falling behind.

My PureBasic StuffFREE STUFF, Scripts & Programs.
My PureBasic Forum ➤ Questions, Requests & Comments.
User avatar
JHPJHP
Addict
Addict
Posts: 2251
Joined: Sat Oct 09, 2010 3:47 am

Re: PureBasic Interface to OpenCV

Post by JHPJHP »

[ REMOVED ] : duplicate post.
Last edited by JHPJHP on Tue Jun 09, 2015 1:05 am, edited 1 time in total.

If you're not investing in yourself, you're falling behind.

My PureBasic StuffFREE STUFF, Scripts & Programs.
My PureBasic Forum ➤ Questions, Requests & Comments.
User avatar
bbanelli
Enthusiast
Enthusiast
Posts: 544
Joined: Tue May 28, 2013 10:51 pm
Location: Europe
Contact:

Re: PureBasic Interface to OpenCV

Post by bbanelli »

Hi JHPJHP,

I've just downloaded latest files from your first post, tried resolution example and it lacks definition in line 3

Code: Select all

*capture.CvCapture
But am I missing something, since I don't see v3.0 link any longer?
"If you lie to the compiler, it will get its revenge."
Henry Spencer
https://www.pci-z.com/
User avatar
JHPJHP
Addict
Addict
Posts: 2251
Joined: Sat Oct 09, 2010 3:47 am

Re: PureBasic Interface to OpenCV

Post by JHPJHP »

Hi bbanelli,

Thank you for the information, I've updated the x86 / x64 interfaces.

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
- function: cvHoughLines2 (option: CV_HOUGH_STANDARD)
-- x86: CvSeq Structure: field [ total ] returns 0 (crashes the interface)
-- x64: CvSeq Structure: field [ total ] returns 0
- legacy binaries not included
Last edited by JHPJHP on Tue Jun 09, 2015 6:11 am, edited 1 time in total.

If you're not investing in yourself, you're falling behind.

My PureBasic StuffFREE STUFF, Scripts & Programs.
My PureBasic Forum ➤ Questions, Requests & Comments.
Locked