RE: video streaming in vfp application

Author: James Harvey

Posted: 2012-05-09 at 09:22:01

Thanks, I used Craig's code, and was able to get the form to load, now I

just need to find a camera to test it out...

James E Harvey

Corresponding Officer/M.I.S.

Hanover Shoe Farms, Inc.

www.hanoverpa.com

office: 717-637-8931

cell: 717-887-2565

fax: 717-637-6766

-----Original Message-----

From: profox-bounces@leafe.com [mailto:profox-bounces@leafe.com] On Behalf

Of Dave Crozier

Sent: Wednesday, May 09, 2012 8:22 AM

To: ProFox Email List

Subject: RE: video streaming in vfp application

I've used the viscomsoft activex before and it is good but you can do it for

nothing courtesy of Craig Boyd.

http://www.tek-tips.com/faqs.cfm?fid=3891

or you can use the coding below to display data from a webcam:

*******************

* START OF CODE

*******************

Local oForm

oForm = Createobject("Tform")

oForm.Show(1)

* end of main

Define Class Tform As Form

#Define WM_CAP_START 0x0400

#Define WM_CAP_DRIVER_CONNECT (WM_CAP_START+10)

#Define WM_CAP_DRIVER_DISCONNECT (WM_CAP_START+11)

#Define WM_CAP_DRIVER_GET_CAPS (WM_CAP_START+14)

#Define WM_CAP_SET_PREVIEW (WM_CAP_START+50)

#Define WM_CAP_SET_OVERLAY (WM_CAP_START+51)

#Define WM_CAP_SET_PREVIEWRATE (WM_CAP_START+52)

#Define WM_CAP_GET_STATUS (WM_CAP_START+54)

#Define WM_CAP_GRAB_FRAME (WM_CAP_START+60)

Width=340

Height=310

AutoCenter=.T.

Caption="Using Video Capture"

MinButton=.F.

MaxButton=.F.

hWindow=0

hCapture=0

capWidth=0

capHeight=0

capOverlay=0

Add Object cmdGetFrame As CommandButton With Default=.T.,;

Left=15, Top=264, Height=27, Width=90, Caption="Get Frame",;

Enabled=.F.

Add Object cmdPreview As CommandButton With Default=.T.,;

Left=106, Top=264, Height=27, Width=100, Caption="Preview

Video",;

Enabled=.F.

Add Object cmdClose As CommandButton With Cancel=.T.,;

Left=207, Top=264, Height=27, Width=70, Caption="Close"

Procedure Activate

If This.hWindow = 0

Declare Integer GetFocus In user32

This.hWindow = GetFocus()

This.CreateCaptureWindow

This.DriverConnect

This.cmdPreview.Click

Endif

Procedure Destroy

This.ReleaseCaptureWindow

endproc

Procedure cmdClose.Click

Thisform.Release

endproc

Procedure cmdGetFrame.Click

Thisform.GetFrame

endproc

Procedure cmdPreview.Click

Thisform.StartPreview

endproc

Procedure GetFrame

#Define WM_CAP_FILE_SAVEDIB (WM_CAP_START + 25)

Local lcFile

LOCAL lcFile

lcFile = "" && File name to create

lcFile = "c:\temp\sample.bmp"

try

MKDIR JUSTPATH( lcFile )

catch

*

endtry

This.msg(WM_CAP_GRAB_FRAME, 0,0)

This.msg(WM_CAP_FILE_SAVEDIB, 0, lcFile,1)

*

endproc

Procedure CreateCaptureWindow

#Define WS_CHILD 0x40000000

#Define WS_VISIBLE 0x10000000

Declare Integer capCreateCaptureWindow In avicap32;

STRING lpszWindowName, Long dwStyle,;

INTEGER x, Integer Y,;

INTEGER nWidth, Integer nHeight,;

INTEGER hParent, Integer nID

This.hCapture = capCreateCaptureWindow("",;

WS_CHILD+WS_VISIBLE,;

10,8,320,240, This.hWindow, 1)

*

endproc

Procedure DriverConnect

This.msg(WM_CAP_DRIVER_CONNECT, 0,0)

If This.IsCaptureConnected()

This.GetCaptureDimensions

Store .T. To This.cmdGetFrame.Enabled,;

THIS.cmdPreview.Enabled

This.Caption = This.Caption + ": connected, " +;

LTRIM(Str(This.capWidth)) + "x" +;

LTRIM(Str(This.capHeight))

Else

This.Caption = This.Caption + ": failed to connect"

Endif

*

endproc

Procedure DriverDisconnect

This.msg(WM_CAP_DRIVER_DISCONNECT, 0,0)

endproc

Procedure ReleaseCaptureWindow

If This.hCapture <> 0

This.DriverDisconnect

Declare Integer DestroyWindow In user32 Integer HWnd

= DestroyWindow(This.hCapture)

This.hCapture = 0

*

Endif

*

endproc

Procedure msg(msg, wParam, Lparam, nMode)

If This.hCapture = 0

Return

Endif

If Vartype(nMode) <> "N" Or nMode=0

Declare Integer SendMessage In user32;

INTEGER HWnd, Integer Msg,;

INTEGER wParam, Integer Lparam

= SendMessage(This.hCapture, msg, wParam, Lparam)

Else

Declare Integer SendMessage In user32;

INTEGER HWnd, Integer Msg,;

INTEGER wParam, String @Lparam

= SendMessage(This.hCapture, msg, wParam, @Lparam)

*

Endif

*

endproc

Function IsCaptureConnected

* analyzing fCaptureInitialized member of the CAPDRIVERCAPS

structure

#Define CAPDRIVERCAPS_SIZE 44

Local cBuffer, nResult

cBuffer = Repli(Chr(0),CAPDRIVERCAPS_SIZE)

This.msg(WM_CAP_DRIVER_GET_CAPS, Len(cBuffer), @cBuffer, 1)

This.capOverlay = buf2dword(Substr(cBuffer,5,4))

nResult = Asc(Substr(cBuffer, 21,1))

Return (nResult<>0)

*

endfunc

Procedure GetCaptureDimensions

* reading uiImageWidth and uiImageHeight members

* of the CAPSTATUS structure

#Define CAPSTATUS_SIZE 76

Local cBuffer

cBuffer = Repli(Chr(0), CAPSTATUS_SIZE)

This.msg(WM_CAP_GET_STATUS, Len(cBuffer), @cBuffer, 1)

This.capWidth = buf2dword(Substr(cBuffer,1,4))

This.capHeight = buf2dword(Substr(cBuffer,5,4))

*

endproc

Procedure StartPreview

This.msg(WM_CAP_SET_PREVIEWRATE, 30,0)

This.msg(WM_CAP_SET_PREVIEW, 1,0)

If This.capOverlay <> 0

This.msg(WM_CAP_SET_OVERLAY, 1,0)

Endif

*

endproc

Procedure StopPreview

This.msg(WM_CAP_SET_PREVIEW, 0,0)

Enddefine

Function buf2dword(lcBuffer)

Return Asc(Substr(lcBuffer, 1,1)) + ;

BitLShift(Asc(Substr(lcBuffer, 2,1)), 8) +;

BitLShift(Asc(Substr(lcBuffer, 3,1)), 16) +;

BitLShift(Asc(Substr(lcBuffer, 4,1)), 24)

endfunc

*

enddefine

*

******************

* END OF CODE

*****************

-----Original Message-----

From: profox-bounces@leafe.com [mailto:profox-bounces@leafe.com] On Behalf

Of James Harvey

Sent: 09 May 2012 13:06

To: 'ProFox Email List'

Subject: video streaming in vfp application

Has anyone tried to provide a live video stream inside a visual foxpro

application?

We'd like to provide a live video stream of each horse as it is being

auctioned, and wanted to have the stream appear inside a "container" on a

vfp form which would include additional textboxes on the form containing

pertinent data for the horse being auctioned.

Research indicates there might be an active x control to put on the form to

handle the video. I found a couple references to ActiveX controls, but was

hoping someone has already had some experience with this subject.

James E Harvey

Corresponding Officer/M.I.S.

Hanover Shoe Farms, Inc.

www.hanoverpa.com

office: 717-637-8931

cell: 717-887-2565

fax: 717-637-6766

[excessive quoting removed by server]

_______________________________________________

Post Messages to: ProFox@leafe.com

Subscription Maintenance: http://leafe.com/mailman/listinfo/profox

OT-free version of this list: http://leafe.com/mailman/listinfo/profoxtech

Searchable Archive: http://leafe.com/archives/search/profox

This message: http://leafe.com/archives/byMID/profox/032601cd2def$1a728980$4f579c80$@hanoverpa.com

** All postings, unless explicitly stated otherwise, are the opinions of the author, and do not constitute legal or medical advice. This statement is added to the messages for those lawyers who are too stupid to see the obvious.

©2012 James Harvey