Subroutine running on....

Hi,

Firstly thanks for taking the time out to read this and even more thanks if anyone manages to come up with a solution...

Problem..

I am writing a video camera surveillance system in VB which basically allows the user to switch camera's, record and playback footage, etc.

The problem exisits in the playback.. Basically the programme stores each frame of the 'video' as a jpg image and the player creates a buffer for each image in the video and plays them back, bit like an old fashioned flip book. This works a treat but the user can not do anything untill the full video has been played. The form will not respond to any toolbar mouse click (ie the pause button) or slider bar.

Here's the code I'm using to display each frame. Its called from another subroutine passing through the frame number for the next frame.

[code]
Private Sub ShowPic(acount As Long)
Dim MyFile As Long
Dim Buffer As String
Dim aVariant As Variant
Dim nLen As Long
Dim nPos As Long
Dim nGet As Long
Dim i As Long

strFile = "c: empyCam
ew" & acount & ".jpg"

MyFile = FreeFile
Open strFile For Binary Access Read As #MyFile
nLen = LOF(MyFile)
Buffer = Space(nLen)
Get #MyFile, , Buffer
Close #MyFile
ReDim abuffer(0 To nLen - 1) As Byte
For i = 1 To Len(Buffer)
abuffer(i - 1) = Asc(Mid(Buffer, i, 1))
Next
aVariant = abuffer
Call CamImage2.SetImage(aVariant, Len(Buffer))
Slider1.Value = acount
Me.Refresh
End Sub
[/code]

Can anyone see why its taking full priority??




[black] Regards [/black]

[Size=4][purple]GazzaLad[/size][/purple]
[Size=1] [Grey]"Just when you thought your software was idiot proof, along comes a better idiot" :-D[/grey] [/Size]
[hr]

Comments

  • : Hi,
    :
    : Firstly thanks for taking the time out to read this and even more thanks if anyone manages to come up with a solution...
    :
    : Problem..
    :
    : I am writing a video camera surveillance system in VB which basically allows the user to switch camera's, record and playback footage, etc.
    :
    : The problem exisits in the playback.. Basically the programme stores each frame of the 'video' as a jpg image and the player creates a buffer for each image in the video and plays them back, bit like an old fashioned flip book. This works a treat but the user can not do anything untill the full video has been played. The form will not respond to any toolbar mouse click (ie the pause button) or slider bar.
    :
    : Here's the code I'm using to display each frame. Its called from another subroutine passing through the frame number for the next frame.
    :
    : [code]
    : Private Sub ShowPic(acount As Long)
    : Dim MyFile As Long
    : Dim Buffer As String
    : Dim aVariant As Variant
    : Dim nLen As Long
    : Dim nPos As Long
    : Dim nGet As Long
    : Dim i As Long
    :
    : strFile = "c: empyCam
    ew" & acount & ".jpg"
    :
    : MyFile = FreeFile
    : Open strFile For Binary Access Read As #MyFile
    : nLen = LOF(MyFile)
    : Buffer = Space(nLen)
    : Get #MyFile, , Buffer
    : Close #MyFile
    : ReDim abuffer(0 To nLen - 1) As Byte
    : For i = 1 To Len(Buffer)
    : abuffer(i - 1) = Asc(Mid(Buffer, i, 1))
    : Next
    : aVariant = abuffer
    : Call CamImage2.SetImage(aVariant, Len(Buffer))
    : Slider1.Value = acount
    : Me.Refresh
    : End Sub
    : [/code]
    :
    : Can anyone see why its taking full priority??

    VB is not multithreaded. Not easily, at least. When you call CamImage2.SetImage(), your code will block there until that call returns. If that procedure is doing a lot of stuff, then your code will block for a long time.


    [size=5][italic][blue][RED]i[/RED]nfidel[/blue][/italic][/size]

  • : : Hi,
    : :
    : : Firstly thanks for taking the time out to read this and even more thanks if anyone manages to come up with a solution...
    : :
    : : Problem..
    : :
    : : I am writing a video camera surveillance system in VB which basically allows the user to switch camera's, record and playback footage, etc.
    : :
    : : The problem exisits in the playback.. Basically the programme stores each frame of the 'video' as a jpg image and the player creates a buffer for each image in the video and plays them back, bit like an old fashioned flip book. This works a treat but the user can not do anything untill the full video has been played. The form will not respond to any toolbar mouse click (ie the pause button) or slider bar.
    : :
    : : Here's the code I'm using to display each frame. Its called from another subroutine passing through the frame number for the next frame.
    : :
    : : [code]
    : : Private Sub ShowPic(acount As Long)
    : : Dim MyFile As Long
    : : Dim Buffer As String
    : : Dim aVariant As Variant
    : : Dim nLen As Long
    : : Dim nPos As Long
    : : Dim nGet As Long
    : : Dim i As Long
    : :
    : : strFile = "c: empyCam
    ew" & acount & ".jpg"
    : :
    : : MyFile = FreeFile
    : : Open strFile For Binary Access Read As #MyFile
    : : nLen = LOF(MyFile)
    : : Buffer = Space(nLen)
    : : Get #MyFile, , Buffer
    : : Close #MyFile
    : : ReDim abuffer(0 To nLen - 1) As Byte
    : : For i = 1 To Len(Buffer)
    : : abuffer(i - 1) = Asc(Mid(Buffer, i, 1))
    : : Next
    : : aVariant = abuffer
    : : Call CamImage2.SetImage(aVariant, Len(Buffer))
    : : Slider1.Value = acount
    : : Me.Refresh
    : : End Sub
    : : [/code]
    : :
    : : Can anyone see why its taking full priority??
    :
    : VB is not multithreaded. Not easily, at least. When you call CamImage2.SetImage(), your code will block there until that call returns. If that procedure is doing a lot of stuff, then your code will block for a long time.
    :
    :
    : [size=5][italic][blue][RED]i[/RED]nfidel[/blue][/italic][/size]
    :
    :

    It could also be the number of sequential calls to the function. Try putting a DoEvents statement somewhere!

    Greets...
    Richard

  • : Hi,
    :
    : Firstly thanks for taking the time out to read this and even more thanks if anyone manages to come up with a solution...
    :
    : Problem..
    :
    : I am writing a video camera surveillance system in VB which basically allows the user to switch camera's, record and playback footage, etc.
    :
    : The problem exisits in the playback.. Basically the programme stores each frame of the 'video' as a jpg image and the player creates a buffer for each image in the video and plays them back, bit like an old fashioned flip book. This works a treat but the user can not do anything untill the full video has been played. The form will not respond to any toolbar mouse click (ie the pause button) or slider bar.
    :
    : Here's the code I'm using to display each frame. Its called from another subroutine passing through the frame number for the next frame.
    :
    : [code]
    : Private Sub ShowPic(acount As Long)
    : Dim MyFile As Long
    : Dim Buffer As String
    : Dim aVariant As Variant
    : Dim nLen As Long
    : Dim nPos As Long
    : Dim nGet As Long
    : Dim i As Long
    :
    : strFile = "c: empyCam
    ew" & acount & ".jpg"
    :
    : MyFile = FreeFile
    : Open strFile For Binary Access Read As #MyFile
    : nLen = LOF(MyFile)
    : Buffer = Space(nLen)
    : Get #MyFile, , Buffer
    : Close #MyFile
    : ReDim abuffer(0 To nLen - 1) As Byte
    : For i = 1 To Len(Buffer)
    : abuffer(i - 1) = Asc(Mid(Buffer, i, 1))
    : Next
    : aVariant = abuffer
    : Call CamImage2.SetImage(aVariant, Len(Buffer))
    : Slider1.Value = acount
    : Me.Refresh
    : End Sub
    : [/code]
    :
    : Can anyone see why its taking full priority??
    :
    :
    :
    :
    : [black] Regards [/black]
    :
    : [Size=4][purple]GazzaLad[/size][/purple]
    : [Size=1] [Grey]"Just when you thought your software was idiot proof, along comes a better idiot" :-D[/grey] [/Size]
    : [hr]
    :
    I've never used but if you use AxisCamControl, there is On_Click event.
    Take a look at followong link. May be that'll help
    http://www.axis.com/techsup/cam_servers/dev/files/AxisCamControl.pdf
  • Doevents worked a treat..

    Thanks Richard!!



    [black] Regards [/black]

    [Size=4][purple]GazzaLad[/size][/purple]
    [Size=1] [Grey]"Just when you thought your software was idiot proof, along comes a better idiot" :-D[/grey] [/Size]
    [hr]

Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories