PureBasic Interface to OpenCV

Developed or developing a new product in PureBasic? Tell the world about it.
wilbert
PureBasic Expert
PureBasic Expert
Posts: 3942
Joined: Sun Aug 08, 2004 5:21 am
Location: Netherlands

Re: PureBasic Interface to OpenCV

Post by wilbert »

JHPJHP wrote:Thank you for your support, and for taking the time to explain the process :!:
It's also helpful for myself JHPJHP.
On Windows it might not be common but some OSX core libraries also pass structures by value needing the same kind of workarounds if you want to use them with PureBasic.
Windows (x64)
Raspberry Pi OS (Arm64)
User avatar
JHPJHP
Addict
Addict
Posts: 2252
Joined: Sat Oct 09, 2010 3:47 am

Re: PureBasic Interface to OpenCV

Post by JHPJHP »

Hi wilbert,

It's good to hear that we're both benefiting from this collaboration.

I'm not sure if you looked at the Windows interface, the declarations in all three packages are not only different from the documentation, but also from each other.
- what had taken me hours and sometimes days to figure out, you've been solving in minutes for the OSX interface

Updated the OSX interface:
- converted 10 examples
-- cv_dithering_1.pb: implementation of the Floyd-Steinberg dithering algorithm applied to a gray-scale image
-- cv_dithering_2.pb: implementation of the Floyd-Steinberg dithering algorithm applied to a color image
-- cv_floodfill.pb: demonstration of the FloodFill function, filling a connected component with a given color
-- cv_mov_runningavg_2.pb: calculates the weighted sum of the input image and the accumulator, so that the new image becomes a running average of a frame sequence
-- cv_overlay_2.pb: calculates the weighted sum of two arrays
-- cv_seam_carving_2.pb: deleting vertical seams in an image by calculating the intensity of gray-scale pixels
-- cv_spider_web_1.pb: draw a Spider Web sketch from a color image
-- cv_spider_web_2.pb: draw a Spider Web sketch from a gray-scale image
-- cv_transparent_2.pb: flood fill a color area to transparency, applied when the image has been saved to a PNG file
-- cv_watershed.pb: performs a marker-based image segmentation using the watershed algorithm

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

My PureBasic StuffFREE STUFF, Scripts & Programs.
My PureBasic Forum ➤ Questions, Requests & Comments.
wilbert
PureBasic Expert
PureBasic Expert
Posts: 3942
Joined: Sun Aug 08, 2004 5:21 am
Location: Netherlands

Re: PureBasic Interface to OpenCV

Post by wilbert »

Hi JHPJHP,

You're fast at converting these examples.
JHPJHP wrote:the declarations in all three packages are not only different from the documentation, but also from each other.
It would be much easier if there would only be one calling convention. Unfortunately that's not the case.
The way procedure arguments are passed to a procedure varies a lot :shock:
JHPJHP wrote:cv_mov_runningavg_2.pb
Intriguing to watch for some time :)
Windows (x64)
Raspberry Pi OS (Arm64)
User avatar
JHPJHP
Addict
Addict
Posts: 2252
Joined: Sat Oct 09, 2010 3:47 am

Re: PureBasic Interface to OpenCV

Post by JHPJHP »

Updated the OSX interface:
- added 10 examples
-- cv_doodle.pb: utilizing OpenCV's mouse callback, adds the ability to doodle on the loaded image
-- cv_drawing.pb: a demonstration of OpenCV's drawing and text output functions
-- cv_draw_spiral.pb: draw a circular or square spiral
-- cv_parametric_curve.pb: Parametric Curve: A curve defined as a function of independent variables
-- cv_resize.pb: resizes an image to a specified percent
-- cv_siemens_star.pb: Siemens Star: A pattern used to test the resolution of optical instruments, printers and displays
-- cv_split_merge.pb: divides a multi-channel array into several single-channel arrays, then combines them excluding 1 channel to create a new multi-channel array
-- cv_threshold_1.pb: applies a fixed-level threshold to each array element
-- cv_threshold_2.pb: applies an adaptive threshold to each array element
-- le_delaunay_2.pb: manual construction of delaunay triangulation

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

My PureBasic StuffFREE STUFF, Scripts & Programs.
My PureBasic Forum ➤ Questions, Requests & Comments.
wilbert
PureBasic Expert
PureBasic Expert
Posts: 3942
Joined: Sun Aug 08, 2004 5:21 am
Location: Netherlands

Re: PureBasic Interface to OpenCV

Post by wilbert »

JHPJHP wrote:cv_drawing.pb: a demonstration of OpenCV's drawing and text output functions
Good demo :)
Windows (x64)
Raspberry Pi OS (Arm64)
User avatar
JHPJHP
Addict
Addict
Posts: 2252
Joined: Sat Oct 09, 2010 3:47 am

Re: PureBasic Interface to OpenCV

Post by JHPJHP »

Hi wilbert,

I think you may find a couple more interesting examples in this new batch...

Updated the OSX interface:
- converted 10 examples
-- cv_cam_flowfarneback.pb: dense optical flow technique using the Gunnar Farneback algorithm
-- cv_cam_flowpyrlk_1.pb: sparse optical flow technique using the Lucas-Kanade algorithm
-- cv_cam_flowpyrlk_2.pb: Sparse optical flow technique using the Lucas-Kanade algorithm
-- cv_cam_goodfeatures.pb: determines strong corners on an image indicated by circles
-- cv_copymakeborder.pb: shows OpenCV's available border styles on a loaded image
-- cv_fractal_2.pb: Fractal Art: Created by calculating fractal objects represented as images
-- cv_fractal_3.pb: generates a Mandelbrot Set, the most popular geometrical fractal
-- cv_fractal_4.pb: generates a Julia Set, a popular geometrical fractal
-- cv_histogram_1.pb: calculates a histogram for the Red, Green, and Blue channels of an image
-- cv_histogram_2.pb: calculates a histogram based on brightness and contrast levels

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

My PureBasic StuffFREE STUFF, Scripts & Programs.
My PureBasic Forum ➤ Questions, Requests & Comments.
wilbert
PureBasic Expert
PureBasic Expert
Posts: 3942
Joined: Sun Aug 08, 2004 5:21 am
Location: Netherlands

Re: PureBasic Interface to OpenCV

Post by wilbert »

JHPJHP wrote:I think you may find a couple more interesting examples in this new batch...
cv_fractal_2.pb is my favorite of these ones. It looks beautiful :)
It's only a bit hard to change the sliders on my computer.
Windows (x64)
Raspberry Pi OS (Arm64)
User avatar
JHPJHP
Addict
Addict
Posts: 2252
Joined: Sat Oct 09, 2010 3:47 am

Re: PureBasic Interface to OpenCV

Post by JHPJHP »

Hi wilbert,

I expected the optical flow examples would have been of more interest, as they were for me; to each his own :)

I agree that the sliders weren't as smooth as they could be, which was the reason I originally included presets, but I'm glad you'd mentioned it.
- updated the example cv_fractal_2.pb in all packages
Last edited by JHPJHP on Sun Jun 26, 2016 7:40 pm, 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.
wilbert
PureBasic Expert
PureBasic Expert
Posts: 3942
Joined: Sun Aug 08, 2004 5:21 am
Location: Netherlands

Re: PureBasic Interface to OpenCV

Post by wilbert »

Thanks for updating the example JHPJHP. It works much better now.
JHPJHP wrote:I would have expected the optical flow examples would have been of more interest, at least they were for me; to each his own :)
Normally I rarely use my webcam but I do like art. That might explain the difference :)
Windows (x64)
Raspberry Pi OS (Arm64)
User avatar
JHPJHP
Addict
Addict
Posts: 2252
Joined: Sat Oct 09, 2010 3:47 am

Re: PureBasic Interface to OpenCV

Post by JHPJHP »

Hi wilbert,

Not many artsy examples left to convert, but I find the eclectic nature of OpenCV most appealing.

Updated the OSX interface:
- converted 10 examples
-- cv_cam_foreground.pb: displays a threshold foreground view using filters to return the difference between frames
-- cv_cam_hsv_bgr.pb: display the HSV and BGR color space values determined by the X/Y mouse pointer location
-- cv_cam_skin_detection_1.pb: skin detection using various filters applied against the YCrCb (Luma [Y] and Chroma [CrCb]) color space
-- cv_cornerharris_1.pb: calculates a feature map for corner detection using the Harris edge detector
-- cv_cornerharris_2.pb: calculates a feature map for corner detection using the Harris edge detector
-- cv_mask_black.pb: create an image mask by replacing any non-black pixels with white
-- cv_mask_color.pb: create an image mask by replacing any pixel colors that fall within the selected range with black, and any other pixels with white
-- cv_standard_deviation.pb: applies Standard Deviation to an image by calculating the square root of the variance
-- cv_thinning_2.pb: a five stage two-dimensional filter applied to a grayscale image producing a skeleton effect
-- cv_thinning_3.pb: repeated iterations using multiple filters on a grayscale image producing a skeleton effect

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

My PureBasic StuffFREE STUFF, Scripts & Programs.
My PureBasic Forum ➤ Questions, Requests & Comments.
wilbert
PureBasic Expert
PureBasic Expert
Posts: 3942
Joined: Sun Aug 08, 2004 5:21 am
Location: Netherlands

Re: PureBasic Interface to OpenCV

Post by wilbert »

Thanks again for the examples JHPJHP
JHPJHP wrote:Not many artsy examples left to convert, but I find the eclectic nature of OpenCV most appealing.
Well, the cv_standard_deviation example looks nice and artsy :)
Windows (x64)
Raspberry Pi OS (Arm64)
User avatar
JHPJHP
Addict
Addict
Posts: 2252
Joined: Sat Oct 09, 2010 3:47 am

Re: PureBasic Interface to OpenCV

Post by JHPJHP »

Hi wilbert,

You are most welcome... You were a big part in bringing the interface from Windows to OSX.

Updated the OSX interface:
- converted 10 examples
-- cv_cam_convexitydefects.pb: calculates the contour areas, finding the convex hull of point sets to convexity defects
-- cv_cam_DCT.pb: performs a discrete cosine transform of a 1D array, displaying its power spectrum
-- cv_cam_detect_hand.pb: contour extraction and calculation is used to determine finger, palm, and depth locations
-- cv_cam_DFT.pb: performs a discrete Fourier transform of a 1D floating-point array, displaying its power spectrum
-- cv_cam_skin_detection_2.pb: detect skin tones using the HSV (Hue, Saturation and Value) color space
-- cv_cam_skin_detection_3.pb: detect skin tones using the YUV (Luma [Y] and Chroma [UV]) color space
-- cv_cam_skin_detection_4.pb: detect skin tones using the YCrCb (Luma [Y] and Chroma [CrCb]) color space
-- cv_cam_skin_detection_5.pb: detect skin tones using the RGB (Red, Green and Blue) color space
-- cv_cam_skin_detection_6.pb: detect skin tones using the RG (Red and Green) color space
-- le_stitching_2.pb: stitch together 2, 3, 4, and 5 images; based on the SIFT (Scale Invariant Feature Transform) algorithm

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

My PureBasic StuffFREE STUFF, Scripts & Programs.
My PureBasic Forum ➤ Questions, Requests & Comments.
wilbert
PureBasic Expert
PureBasic Expert
Posts: 3942
Joined: Sun Aug 08, 2004 5:21 am
Location: Netherlands

Re: PureBasic Interface to OpenCV

Post by wilbert »

JHPJHP wrote:Updated the OSX interface:
- converted 10 examples
Thanks again :)
You probably aren't surprised the stitching example is my favorite.
But in general, I'm still impressed by what this library can do. 8)
Windows (x64)
Raspberry Pi OS (Arm64)
User avatar
Lunasole
Addict
Addict
Posts: 1091
Joined: Mon Oct 26, 2015 2:55 am
Location: UA
Contact:

Re: PureBasic Interface to OpenCV

Post by Lunasole »

@JHPJHP are your binaries compiled with SSE2 enabled?

I'm getting 0xc000001d critical error on some systems with any application or example compiled using those bindings, thus suspecting SSE2-related problems.
"W̷i̷s̷h̷i̷n̷g o̷n a s̷t̷a̷r"
User avatar
JHPJHP
Addict
Addict
Posts: 2252
Joined: Sat Oct 09, 2010 3:47 am

Re: PureBasic Interface to OpenCV

Post by JHPJHP »

Hi wilbert,

I'm not surprised that the stitching example was your favorite :)

As always I appreciate your support and acknowledgement.

------------------------------------------------

Hi Lunasole,

For the OSX build the SSE, SSE2, and SSE3 options were checked, I believe the same was true for the Windows binaries.

------------------------------------------------

Updated the OSX interface:
- converted 10 examples
-- cv_cam_haar_transform.pb: builds a direct and inverse Haar wavelet transform
-- cv_cam_haardetect_face.pb: tries to detect a frontal-face using HaarCascades
-- cv_cam_logo.pb: adds a logo with border to a webcam stream by utilizing the Region Of Interest functions
-- cv_cam_saveimage.pb: images are saved to a folder at one second intervals
-- cv_cam_writeframe_1.pb: video is saved to a folder
-- cv_cam_writeframe_2.pb: images are saved to a folder
-- cv_chessboard.pb: generates the top view of a chessboard pattern from its perspective view
-- cv_convertimage.pb: converts from one image to another with optional vertical flip
-- pb_gl_cam_cube.pb: using OpenGL and textures, the webcam interface is displayed onto the surfaces of a rotating cube
-- pb_gl_cam_invert.pb: using OpenGL and textures, the webcam interface is displayed onto the front and inverted onto the back of a revolving rectangle

cv_cam_writeframe_1.pb:
- 8BPS codec: used to compress planar RGB video in Quicktime files
-- a video created using this example will be very large due to the codec; OSX has a limited selection compared to Windows

pb_gl_cam_cube.pb & pb_gl_cam_invert.pb: needs some work due to the poor video quality.
- I believe the problem is in the Procedure ConvertIplToTexture
-- I thought changing the parameters from #GL_RGB to #GL_RGBA would resolve the issue, but it only made the video stream recognizable

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

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