Page 1 of 60

PureBasic Interface to OpenCV

Posted: Fri Nov 22, 2013 2:46 pm
by JHPJHP

Re: OpenCV (v2)

Posted: Fri Nov 22, 2013 6:24 pm
by Little John
Hello JHPJHP,

that looks very interesting.

Unfortunately, I'm not able to run any of the examples (using PB 5.21 LTS on Windows XP x86).
I always get a German error message which translates to something like
PureBasic_Compilation0.exe - Entry point not found
---------------------------
The procedure entry point "GetTickCount64" was not found in the DLL "KERNEL32.dll".

Re: OpenCV (v2)

Posted: Fri Nov 22, 2013 6:54 pm
by JHPJHP
Hi Little John,

AAT and myself have tested the examples using earlier versions of the OpenCV binaries and C Runtime files, and because of some adverse results I elected too remove them; hindsight being 20/20 - I'll add them back later in the day.

Let me know if the new binaries work for you.

Re: OpenCV (v2)

Posted: Fri Nov 22, 2013 9:39 pm
by Mythros
Hi, @JHP!

I have tried your examples, and they are getting better & better each time!

Remember that thread I posted earlier about adding sound to the video recording?

If you integrate THAT, I'm sure people will be ALL over it! =D

Thanks again for your contribution, and let me know when you're ready for me to perma-host this project! :)

Regards,

Mythros

Re: OpenCV (v2)

Posted: Sat Nov 23, 2013 3:25 am
by AAT
Yes! It happened! :D
Thanks, JHPJHP!

P.S. I found a solution to the problem about which you wrote (#CV_CAP_PROP_FRAME_HEIGHT - returns 0 (XP only)).
Edited.

Background:
1 . you can't use OpenCV libraries compiled with VC11 in WindowsXP because they use function calls missing in WindowsXP (for example, GetTickCount64);
2 . you have to use the OpenCV libraries compiled with VC10 (VC9) for WindowsXP, they can also be used Windows7 (Vista);
3 . when using OpenCV libraries compiled with VC10 (VC9), some OpenCV functions work incorrectly, for example
cvGetCaptureProperty(*capture, #CV_CAP_PROP_FRAME_HEIGHT)
always returns 1 regardless of an Windows version (XP...7).

The problem has a very simple solution requires a complete and accurate prototyping functions OpenCV.
I specified type of returned value in a prototype of the cvGetCaptureProperty function and it returned correct value instead of 1.

I edited the file opencv.pbi:
- constants are added
- types of returned values are added in prototypes of functions (where I could)
- comments in prototypes of functions are added

Please check my additions.

Re: OpenCV (v2)

Posted: Sat Nov 23, 2013 10:09 am
by AAT
Edited opencv.pbi:

Code: Select all

IncludePath "binaries"

#CV_WINDOW_NORMAL                       = 0
#CV_WINDOW_AUTOSIZE                     = 1
#CV_GUI_NORMAL                          = $10
#CV_WINDOW_FREERATIO                    = $100

#CV_CAP_PROP_POS_MSEC                   = 0
#CV_CAP_PROP_POS_FRAMES                 = 1
#CV_CAP_PROP_POS_AVI_RATIO              = 2
#CV_CAP_PROP_FRAME_WIDTH                = 3
#CV_CAP_PROP_FRAME_HEIGHT               = 4
#CV_CAP_PROP_FPS                        = 5
#CV_CAP_PROP_POS_FOURCC                 = 6
#CV_CAP_PROP_POS_FRAME_COUNT            = 7
;#CV_CAP_PROP_BRIGHTNESS                 = 8    ;AAT 
;#CV_CAP_PROP_CONTRAST                   = 9    ;AAT 
;#CV_CAP_PROP_SATURATION                 = 10   ;AAT 
;#CV_CAP_PROP_HUE                        = 11   ;AAT 

;AAT Start
#CV_CAP_PROP_DC1394_OFF                 = -4    ; turn the feature off (Not controlled manually nor automatically)
#CV_CAP_PROP_DC1394_MODE_MANUAL         = -3    ; set automatically when a value of the feature is set by the user
#CV_CAP_PROP_DC1394_MODE_AUTO           = -2    ;
#CV_CAP_PROP_DC1394_MODE_ONE_PUSH_AUTO  = -1    ;
#CV_CAP_PROP_POS_MSEC                   = 0     ;
#CV_CAP_PROP_POS_FRAMES                 = 1     ;
#CV_CAP_PROP_POS_AVI_RATIO              = 2     ;
#CV_CAP_PROP_FRAME_WIDTH                = 3     ;
#CV_CAP_PROP_FRAME_HEIGHT               = 4     ;
#CV_CAP_PROP_FPS                        = 5     ;
#CV_CAP_PROP_FOURCC                     = 6     ;
#CV_CAP_PROP_FRAME_COUNT                = 7     ;
#CV_CAP_PROP_FORMAT                     = 8     ;
#CV_CAP_PROP_MODE                       = 9     ;
#CV_CAP_PROP_BRIGHTNESS                 = 10    ;
#CV_CAP_PROP_CONTRAST                   = 11    ;
#CV_CAP_PROP_SATURATION                 = 12    ;
#CV_CAP_PROP_HUE                        = 13    ;
#CV_CAP_PROP_GAIN                       = 14    ;
#CV_CAP_PROP_EXPOSURE                   = 15    ;
#CV_CAP_PROP_CONVERT_RGB                = 16    ;
#CV_CAP_PROP_WHITE_BALANCE_BLUE_U       = 17    ;
#CV_CAP_PROP_RECTIFICATION              = 18    ;
#CV_CAP_PROP_MONOCROME                  = 19    ;
#CV_CAP_PROP_SHARPNESS                  = 20    ;
#CV_CAP_PROP_AUTO_EXPOSURE              = 21    ; exposure control done by camera; user can adjust refernce level using this feature
#CV_CAP_PROP_GAMMA                      = 22    ;
#CV_CAP_PROP_TEMPERATURE                = 23    ;
#CV_CAP_PROP_TRIGGER                    = 24    ;
#CV_CAP_PROP_TRIGGER_DELAY              = 25    ;
#CV_CAP_PROP_WHITE_BALANCE_RED_V        = 26    ;
#CV_CAP_PROP_ZOOM                       = 27    ;
#CV_CAP_PROP_FOCUS                      = 28    ;
#CV_CAP_PROP_GUID                       = 29    ;
#CV_CAP_PROP_ISO_SPEED                  = 30    ;
#CV_CAP_PROP_MAX_DC1394                 = 31    ;
#CV_CAP_PROP_BACKLIGHT                  = 32    ;
#CV_CAP_PROP_PAN                        = 33    ;
#CV_CAP_PROP_TILT                       = 34    ;
#CV_CAP_PROP_ROLL                       = 35    ;
#CV_CAP_PROP_IRIS                       = 36    ;
#CV_CAP_PROP_SETTINGS                   = 37    ;

#CV_CAP_PROP_AUTOGRAB                   = 1024  ;     property For highgui class CvCapture_Android only
#CV_CAP_PROP_SUPPORTED_PREVIEW_SIZES_STRING =1025;  readonly; tricky property; returns cpnst char* indeed
#CV_CAP_PROP_PREVIEW_FORMAT             =1026   ;      readonly; tricky property; returns cpnst char* indeed
;AAT End

#CV_LOAD_IMAGE_UNCHANGED                = -1
#CV_LOAD_IMAGE_GRAYSCALE                = 0
#CV_LOAD_IMAGE_COLOR                    = 1
#CV_LOAD_IMAGE_ANYDEPTH                 = 2
#CV_LOAD_IMAGE_ANYCOLOR                 = 4

#CV_IMWRITE_JPEG_QUALITY                = 1
#CV_IMWRITE_PNG_COMPRESSION             = 16
#CV_IMWRITE_PXM_BINARY                  = 32

#CV_FOURCC_PROMPT                       = -1
#CV_FOURCC_DEFAULT                      = 0

#CV_EVENT_MOUSEMOVE                     = 0
#CV_EVENT_LBUTTONDOWN                   = 1
#CV_EVENT_RBUTTONDOWN                   = 2
#CV_EVENT_MBUTTONDOWN                   = 3
#CV_EVENT_LBUTTONUP                     = 4
#CV_EVENT_RBUTTONUP                     = 5
#CV_EVENT_MBUTTONUP                     = 6
#CV_EVENT_LBUTTONDBLCLK                 = 7
#CV_EVENT_RBUTTONDBLCLK                 = 8
#CV_EVENT_MBUTTONDBLCLK                 = 9

#CV_EVENT_FLAG_LBUTTON                  = 1
#CV_EVENT_FLAG_RBUTTON                  = 2
#CV_EVENT_FLAG_MBUTTON                  = 4
#CV_EVENT_FLAG_CTRLKEY                  = 8
#CV_EVENT_FLAG_SHIFTKEY                 = 16
#CV_EVENT_FLAG_ALTKEY                   = 32

#CV_INTER_NEAREST                       = 0
#CV_INTER_LINEAR                        = 1
#CV_INTER_CUBIC                         = 2
#CV_INTER_AREA                          = 3
#CV_INTER_LANCZOS4                      = 4
#CV_INTER_MAX                           = 7
#CV_WARP_FILL_OUTLIERS                  = 8
#CV_WARP_INVERSE_MAP                    = 16

#CV_CVTIMG_DEFAULT                      = 0
#CV_CVTIMG_FLIP                         = 1
#CV_CVTIMG_SWAP_RB                      = 2

#IPL_DEPTH_SIGN                         = $80000000
#IPL_DEPTH_1U                           = 1
#IPL_DEPTH_8U                           = 8
#IPL_DEPTH_16U                          = 16
#IPL_DEPTH_32F                          = 32
#IPL_DEPTH_8S                           = (#IPL_DEPTH_SIGN | 8)
#IPL_DEPTH_16S                          = (#IPL_DEPTH_SIGN | 16)
#IPL_DEPTH_32S                          = (#IPL_DEPTH_SIGN | 32)

#CV_THRESH_BINARY                       = 0
#CV_THRESH_BINARY_INV                   = 1
#CV_THRESH_TRUNC                        = 2
#CV_THRESH_TOZERO                       = 3
#CV_THRESH_TOZERO_INV                   = 4
#CV_THRESH_MASK                         = 7
#CV_THRESH_OTSU                         = 8

#CV_BGR2BGRA                            = 0
#CV_RGB2RGBA                            = #CV_BGR2BGRA
#CV_BGRA2BGR                            = 1
#CV_RGBA2RGB                            = #CV_BGRA2BGR
#CV_BGR2RGBA                            = 2
#CV_RGB2BGRA                            = #CV_BGR2RGBA
#CV_RGBA2BGR                            = 3
#CV_BGRA2RGB                            = #CV_RGBA2BGR
#CV_BGR2RGB                             = 4
#CV_RGB2BGR                             = #CV_BGR2RGB
#CV_BGRA2RGBA                           = 5
#CV_RGBA2BGRA                           = #CV_BGRA2RGBA
#CV_BGR2GRAY                            = 6
#CV_RGB2GRAY                            = 7
#CV_GRAY2BGR                            = 8
#CV_GRAY2RGB                            = #CV_GRAY2BGR
#CV_GRAY2BGRA                           = 9
#CV_GRAY2RGBA                           = #CV_GRAY2BGRA
#CV_BGRA2GRAY                           = 10
#CV_RGBA2GRAY                           = 11
#CV_BGR2BGR565                          = 12
#CV_RGB2BGR565                          = 13
#CV_BGR5652BGR                          = 14
#CV_BGR5652RGB                          = 15
#CV_BGRA2BGR565                         = 16
#CV_RGBA2BGR565                         = 17
#CV_BGR5652BGRA                         = 18
#CV_BGR5652RGBA                         = 19
#CV_GRAY2BGR565                         = 20
#CV_BGR5652GRAY                         = 21
#CV_BGR2BGR555                          = 22
#CV_RGB2BGR555                          = 23
#CV_BGR5552BGR                          = 24
#CV_BGR5552RGB                          = 25
#CV_BGRA2BGR555                         = 26
#CV_RGBA2BGR555                         = 27
#CV_BGR5552BGRA                         = 28
#CV_BGR5552RGBA                         = 29
#CV_GRAY2BGR555                         = 30
#CV_BGR5552GRAY                         = 31
#CV_BGR2XYZ                             = 32
#CV_RGB2XYZ                             = 33
#CV_XYZ2BGR                             = 34
#CV_XYZ2RGB                             = 35
#CV_BGR2YCrCb                           = 36
#CV_RGB2YCrCb                           = 37
#CV_YCrCb2BGR                           = 38
#CV_YCrCb2RGB                           = 39
#CV_BGR2HSV                             = 40
#CV_RGB2HSV                             = 41
#CV_BGR2Lab                             = 44
#CV_RGB2Lab                             = 45
#CV_BayerBG2BGR                         = 46
#CV_BayerGB2BGR                         = 47
#CV_BayerRG2BGR                         = 48
#CV_BayerGR2BGR                         = 49
#CV_BayerBG2RGB                         = #CV_BayerRG2BGR
#CV_BayerGB2RGB                         = #CV_BayerGR2BGR
#CV_BayerRG2RGB                         = #CV_BayerBG2BGR
#CV_BayerGR2RGB                         = #CV_BayerGB2BGR
#CV_COLORCVT_MAX                        = 56

#CV_BLUR_NO_SCALE                       = 0
#CV_BLUR                                = 1
#CV_GAUSSIAN                            = 2
#CV_MEDIAN                              = 3
#CV_BILATERAL                           = 4

#CV_FONT_HERSHEY_SIMPLEX                = 0
#CV_FONT_HERSHEY_PLAIN                  = 1
#CV_FONT_HERSHEY_DUPLEX                 = 2
#CV_FONT_HERSHEY_COMPLEX                = 3
#CV_FONT_HERSHEY_TRIPLEX                = 4
#CV_FONT_HERSHEY_COMPLEX_SMALL          = 5
#CV_FONT_HERSHEY_SCRIPT_SIMPLEX         = 6
#CV_FONT_HERSHEY_SCRIPT_COMPLEX         = 7
#CV_FONT_ITALIC                         = 16

#CV_FILLED                              = -1
#CV_AA                                  = 16

#CV_C                                   = 1
#CV_L1                                  = 2
#CV_L2                                  = 4
#CV_NORM_MASK                           = 7
#CV_RELATIVE                            = 8
#CV_DIFF                                = 16
#CV_MINMAX                              = 32

#CV_DIFF_C                              = (#CV_DIFF | #CV_C)
#CV_DIFF_L1                             = (#CV_DIFF | #CV_L1)
#CV_DIFF_L2                             = (#CV_DIFF | #CV_L2)
#CV_RELATIVE_C                          = (#CV_RELATIVE | #CV_C)
#CV_RELATIVE_L1                         = (#CV_RELATIVE | #CV_L1)
#CV_RELATIVE_L2                         = (#CV_RELATIVE | #CV_L2)

#CV_CN_MAX                              = 512
#CV_CN_SHIFT                            = 3
#CV_DEPTH_MAX                           = (1 << #CV_CN_SHIFT)
#CV_8U                                  = 0
#CV_8S                                  = 1
#CV_16U                                 = 2
#CV_16S                                 = 3
#CV_32S                                 = 4
#CV_32F                                 = 5
#CV_64F                                 = 6
#CV_USRTYPE1                            = 7
#CV_MAT_DEPTH_MASK                      = (#CV_DEPTH_MAX - 1)

Structure IplImage Align #PB_Structure_AlignC
  nSize.i
  ID.i
  nChannels.i
  alphaChannel.i
  depth.i
  colorModel.c[4]
  channelSeq.c[4]
  dataOrder.i
  origin.i
  align.i
  width.i
  height.i
  *roi
  *maskROI
  *imageId
  *tileInfo
  imageSize.i
  *imageData
  widthStep.i
  BorderMode.i[4]
  BorderConst.i[4]
  *imageDataOrigin
EndStructure

Structure cvPoint Align #PB_Structure_AlignC
  x.i
  y.i
EndStructure

Structure cvPoint2f Align #PB_Structure_AlignC
  x.f
  y.f
EndStructure

Structure cvSize Align #PB_Structure_AlignC
  width.i
  height.i
EndStructure

Structure cvRect Align #PB_Structure_AlignC
  x.i
  y.i
  width.i
  height.i
EndStructure

Structure cvFont Align #PB_Structure_AlignC
  nameFont.s
  blue.d
  green.d
  red.d
  alpha.d
  font_face.i
  ascii.i
  greek.i
  cyrillic.i
  hscale.f
  vscale.f
  shear.f
  thickness.i
  dx.f
  line_type.i
EndStructure

Structure cvCompression Align #PB_Structure_AlignC
  paramId.i
  paramValue.i
EndStructure

Structure cvScalar Align #PB_Structure_AlignC
  val.d[4]
EndStructure

Structure cvUserInfo
  uMsg.s
  uValue.l
EndStructure

Macro CV_FOURCC(c1, c2, c3, c4)
  ((Asc(c1) & 255) + ((Asc(c2) & 255) << 8) + ((Asc(c3) & 255) << 16) + ((Asc(c4) & 255) << 24))
EndMacro

Macro CV_RGB(r, g, b)
  (b + (g << 8) + (r << 16))
EndMacro

Macro cvScalar(val0, val1 = 0, val2 = 0, val3 = 0)
  scalar.cvScalar
  scalar\val[0] = val0
  scalar\val[1] = val1
  scalar\val[2] = val2
  scalar\val[3] = val3
EndMacro

Macro cvRealScalar(val0)
  scalar.cvScalar
  scalar\val[0] = val0
  scalar\val[1] = 0
  scalar\val[2] = 0
  scalar\val[3] = 0
EndMacro

Macro cvScalarAll(val0123)
  scalar.cvScalar
  scalar\val[0] = val0123
  scalar\val[1] = val0123
  scalar\val[2] = val0123
  scalar\val[3] = val0123
EndMacro

Macro CV_MAT_DEPTH(flags)
  ((flags) & #CV_MAT_DEPTH_MASK)
EndMacro

Macro CV_MAKETYPE(depth, cn)
  (CV_MAT_DEPTH(depth) + (((cn) - 1) << #CV_CN_SHIFT))
EndMacro

ImportC "opencv_core247.lib"
  cvCreateImage(width.i, height.i, depth.i, channels.i)                                                                                                 ;ToDo IplImage*
  cvCloneImage(*image)                                                                                                                                  ;ToDo IplImage*     
  cvCreateMat(rows.i, cols.i, type.i)                                                                                                                   ;ToDo CvMat*
  cvGetSize(*arr)                                                                                                                                       ;ToDo cvSize
  cvFlip(*src, *dst, flip_mode.i)                                                                                                                       ;void
  cvNormalize(*src, *dst, a.d, b.d, norm_type.i, *mask)                                                                                                 ;void
  cvInitFont(*font, font_face.i, hscale.d, vscale.d, shear.d, thickness.i, line_type.i)                                                                 ;void
  cvPutText(*img, text.p-ascii, x.i, y.i, *font, blue.d, green.d, red.d, alpha.d)                                                                       ;void
  cvRectangle(*img, left.i, top.i, right.i, bottom.i, blue.d, green.d, red.d, alpha.d, thickness.i, line_type.i, shift.i)                               ;void  
  cvRectangleR(*img, x.i, y.i, width.i, height.i, blue.d, green.d, red.d, alpha.d, thickness.i, line_type.i, shift.i)                                   ;void
  cvCircle(*img, x, y, radius.i, blue.d, green.d, red.d, alpha.d, thickness.i, line_type.i, shift.i)                                                    ;void 
  cvLine(*img, x1.i, y1.i, x2.i, y2.i, blue.d, green.d, red.d, alpha.d, thickness.i, line_type.i, shift.i)                                              ;void
  cvEllipse(*img, x.i, y.i, width.i, height.i, angle.d, start_angle.d, end_angle.d, blue.d, green.d, red.d, alpha.d, thickness.i, line_type.i, shift.i) ;void
  cvPolyLine(*img, Array pts.cvPoint(1), npts.i, contours.i, is_closed.b, blue.d, green.d, red.d, alpha.d, thickness.i, line_type.i, shift.i)           ;void
  cvFillPoly(*img, Array pts.cvPoint(1), npts.i, contours.i, blue.d, green.d, red.d, alpha.d, line_type.i, shift.i)                                     ;void  
  cvReleaseMat(*mat)
EndImport

ImportC "opencv_highgui247.lib"
  cvCreateCameraCapture(index.i)                                                                                                                        ;??? 
  cvGetCaptureProperty.d(*capture, property_id.i)                                                                                                       ;AAT    
  cvSetCaptureProperty.i(*capture, property_id.i, value.d)                                                                                              ;AAT
  cvNamedWindow.i(name.p-ascii, flags)                                                                                                                  ;AAT
  cvQueryFrame(*capture)                                                                                                                                ;ToDo IplImage*
  cvLoadImage(filename.p-ascii, flags.i)                                                                                                                ;ToDo IplImage*
  cvSaveImage.i(filenames.p-ascii, *image, *params)                                                                                                     ;AAT
  cvShowImage(name.p-ascii, *image)                                                                                                                     ;void
  cvConvertImage(*src, *dst, flags.i)                                                                                                                   ;???
  cvGetWindowHandle(name.p-ascii)                                                                                                                       ;???
  cvGetWindowName(window_handle)                                                                                                                        ;???
  cvResizeWindow(name.p-ascii, width.i, height.i)                                                                                                       ;void
  cvMoveWindow(name.p-ascii, x.i, y.i)                                                                                                                  ;void
  cvCreateTrackbar.i(trackbar_name.p-ascii, window_name.p-ascii, value.i, count.i, on_change)                                                           ;AAT
  cvGetTrackbarPos.i(trackbar_name.p-ascii, window_name.p-ascii)                                                                                        ;AAT
  cvSetTrackbarPos(trackbar_name.p-ascii, window_name.p-ascii, pos.i)                                                                                   ;void  
  cvSetMouseCallback(*window_name, on_mouse, *param)                                                                                                    ;void 
  cvWaitKey.i(delay.i)                                                                                                                                  ;AAT
  cvDestroyWindow(name.p-ascii)                                                                                                                         ;void
  cvReleaseCapture(*capture)                                                                                                                            ;void
  cvCreateVideoWriter(filename.p-ascii, fourcc.i, fps.d, *frame_size, is_color.i)                                                                       ;ToDo CvVideoWriter*
  cvWriteFrame.i(*writer, *image)                                                                                                                       ;AAT
  cvReleaseVideoWriter(*writer)                                                                                                                         ;void
EndImport

ImportC "opencv_imgproc247.lib"
  cvResize(*src, *dst, interpolation.i)                                                                                                                 ;void
  cv2DRotationMatrix(x.f, y.f, angle.d, scale.d, *map_matrix)                                                                                           ;ToDo CvMat*
  cvWarpAffine(*src, *dst, map_matrix, flags.i, blue.d, green.d, red.d, alpha.d)                                                                        ;void
  cvThreshold.d(*src, *dst, threshold.d, max_value.d, threshold_type.i)                                                                                 ;AAT
  cvCanny(*image, *edges, threshold1.d, threshold2.d, aperture_size.i, L2gradient.b)                                                                    ;void
  cvCvtColor(*src, *dst, code.i, dstCn.i)                                                                                                               ;void
  cvSmooth(*src, *dst, smoothtype.i, size1.i, size2.i, sigma1.d, sigma2.d)                                                                              ;void
  cvReleaseImage(*image)                                                                                                                                ;void
EndImport

PrototypeC.d protoThreshold(*src, *dst, threshold.d, max_value.d, threshold_type.i)
Global cvThreshold2.protoThreshold

imgproc247 = OpenLibrary(#PB_Any, "opencv_imgproc247.dll")

If imgproc247 : cvThreshold2 = GetFunction(imgproc247, "cvThreshold") : EndIf
; IDE Options = PureBasic 5.21 LTS (Windows - x86)
; Folding = --
; DisableDebugger

Re: OpenCV (v2)

Posted: Sun Nov 24, 2013 2:32 am
by JHPJHP
Thanks AAT... I can respect the amount of time it probably took to figure out that it was the return value causing the problem. The last time we talked you were "Walking the DLL" trying to determine the differences between versions.

You probably didn't notice - I had updated the project prior to your post, modifying Structures & Data Types. The project has again been updated too only include your changes that now apply (including the extensive Constants list and cvGetCaptureProperty fix under XP), as well as a few additions I've made.

- because it was the same day I started this thread, I only mentioned the update in my original post, in future I will additionally create a new post, notifying that there has been a change

My updates stem from testing in PureBasic x64, and something I should have realized from other projects when converting from C to PureBasic... Int in C needs to be converted to a Long in PureBasic (unless otherwise specified); an Int is 4 bytes under x86 but 8 bytes under x64 - throwing off Structure alignment.

- as there is still a problem with OpenCV working under PureBasic x64, there will probably be additional changes to the IplImage Structure


Cheers - and nice work!

Re: OpenCV (v2)

Posted: Sun Nov 24, 2013 8:08 am
by AAT
Examples works fine in WindowsXP with libraries compiled with VC10.
Some troubles exist in functions
- cvWarpAffine(*resize, *rotate, *map_matrix, #CV_INTER_MAX + #CV_WARP_FILL_OUTLIERS, 0, 0, 0, 0)
with parameter #CV_INTER_MAX (cv_rotate examples) - i have a message "Microsoft Visual C++ Runtime Library Runtime Error! This application has requested the Runtime to terminate it in an unusual way."
- cvSobel(*resize, *resize, 0, 3, 3)
with third derivatives - i have the same Runtime Error.

I try to prototype function cvAdaptiveThreshold. It works! :)

Addition to cv_functions.pbi

Code: Select all

ImportC "opencv_imgproc247.lib"
...
  cvAdaptiveThreshold(*src, *dst, max_value.d, adaptive_method, threshold_type, blocksize.l, paraml.d)  
EndImport
Additions to cv_constants.pbi

Code: Select all

#CV_ADAPTIVE_THRESH_MEAN_C     = 0 
#CV_ADAPTIVE_THRESH_GAUSSIAN_C = 1
Replacement in cv_threshold.pb

Code: Select all

;    threshold.d = cvThreshold(*edges, *edges, 50, 255, #CV_THRESH_BINARY); + #CV_THRESH_OTSU)
    cvAdaptiveThreshold(*edges, *edges, 255, #CV_ADAPTIVE_THRESH_GAUSSIAN_C, #CV_THRESH_BINARY_INV, 3, 8) 
Good luck!

Re: OpenCV (v2)

Posted: Sun Nov 24, 2013 9:40 am
by JHPJHP
Tested cvWarpAffine & cvSobel examples with Windows XP, but I didn't receive an error.
- try substituting the C Runtime files you're using with the ones located in \binaries\cRt (v11)
-- msvcp110.dll, msvcr110.dll

cvAdaptiveThreshold has been added as its own example; the two Threshold functions offer very different effects
- constants added to cv_constants.pbi

I've also made some minor changes and additions - the most significant being the cvMat Structure.

Cheers!

Re: OpenCV (v2)

Posted: Sun Nov 24, 2013 9:53 am
by Little John
Hi JHPJHP,

I can confirm that it works now here on Windows XP 32 bit.
Many thanks for all your work!

Re: OpenCV (v2)

Posted: Sun Nov 24, 2013 9:15 pm
by JHPJHP
Great to hear Little John.

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

A new example has been added: cv_border.pb, including some additional Constants.
- also applied the border effect to: cv_canny.pb

Re: OpenCV (v2)

Posted: Sun Nov 24, 2013 9:19 pm
by Mythros
There's GOT to be a way to get the video onto a 3D texture and turn on / off sound.

Re: OpenCV (v2)

Posted: Sun Nov 24, 2013 9:38 pm
by JHPJHP
Hi Mythros,

Please try the Coding Questions forum, this thread is to demonstrate OpenCV compatibility with PureBasic, and I'd like to keep it on point. While audio can be added to OpenCV video, it's not inherent and would deviate from that purpose.

Thanks.

Re: OpenCV (v2)

Posted: Mon Nov 25, 2013 12:27 am
by JHPJHP
Added a few new functions and another example: cv_filter2d.pb
- this filter appears to make images more clear / crisp

NB*: Most of the image examples are set with a high filter setting to emphasize the effect, not really the recommended use. For some of the examples, there are calculations (not included) that precede the function to optimize the effect. A trackbar could also be added to most of the examples to demonstrate the effect better: cv_flip.pb & cv_rotate2.pb shows how this can be done.

I've opted to create separate examples as opposed to combining them, to assist anyone else interested in this topic, by keeping things simple but functional.

Cheers!

Re: OpenCV (v2)

Posted: Mon Nov 25, 2013 3:42 am
by JHPJHP
Renamed some examples.
- if an example uses the same (main) functions as another example, but produces different results, the name is appended with _1a, _1b, etc.
- if an example is designed to produce similar results as another example, but uses different functions, the name is appended with _2, _3, etc.

Added an extensive list of Constants, a few Functions, and 2 examples.
- cv_distance.pb
-- utilizes the new functions
- cv_threshold_1b.pb
-- a color version of cv_threshold_1a.pb (formally named cv_threshold1.pb)

Cheers!