fbvideoclass (Windows 32/64-bit)

For issues with communication ports, protocols, etc.
D.J.Peters
Posts: 8586
Joined: May 28, 2005 3:28
Contact:

fbvideoclass (Windows 32/64-bit)

Post by D.J.Peters »

For my 3d printer/scanner project I need simple video capturing in FreeBASIC so I rewrote my old fbvideocam stuff.

download: fbvideoclass.zip from: Jan 15, 2020

Tested on Windows 32-bit and 64-bit !
(1 PCIE TV-card 1 USB videograbber and 2 highquality cameras and 3 simple USB web cams)

Joshy
Last edited by D.J.Peters on Oct 12, 2022 18:50, edited 4 times in total.
BasicCoder2
Posts: 3904
Joined: Jan 01, 2009 7:03
Location: Australia

Re: fbvideoclass (windows)

Post by BasicCoder2 »

Sorry can't check the Window 64-bit.
However using the laptop webcam (faster than any usb plug in cam) test01 and test02 give normal still images whereas test03 and test06 produce moving images of subject matter but consist of vertical lines and with green and pink colors.
I think I had this problem when you first posted your fbvideoclass.
The escapi.bi works ok.

How are you going to use web cam images with your 3D printer? I imagined an object being scanned by a laser while rotated to extract its shape.
Or maybe its shadow outline as it is rotated.
.
MrSwiss
Posts: 3910
Joined: Jun 02, 2013 9:27
Location: Switzerland

Re: fbvideoclass (windows)

Post by MrSwiss »

D.J.Peters wrote:Does it works on your windows 64-bit ? (I don't know)
No, not working on FBC x64, due to 32bit ASM, in ConvertRGB ().
Tested: test01.bas -- WIN 10, pro x64 / FBC 1.05.0 (64bit).
test01.asm: Assembler messages:
test01.asm:2358: Error: incorrect register `ebx' used with `q' suffix
test01.asm:2361: Error: incorrect register `edi' used with `q' suffix
test01.asm:2370: Error: operand type mismatch for `push'
test01.asm:2403: Error: operand type mismatch for `pop'
D.J.Peters
Posts: 8586
Joined: May 28, 2005 3:28
Contact:

Re: fbvideoclass (windows)

Post by D.J.Peters »

test it again please

added: #if __FB_64BIT__ and one more YUY2 format

Joshy
BasicCoder2
Posts: 3904
Joined: Jan 01, 2009 7:03
Location: Australia

Re: fbvideoclass (windows)

Post by BasicCoder2 »

It now works with the web cam integrated with the laptop.
Now can we capture multiple images as we can using the escapi.bi and easily process the images ?
.
D.J.Peters
Posts: 8586
Joined: May 28, 2005 3:28
Contact:

Re: fbvideoclass (windows)

Post by D.J.Peters »

All my 5 cams works perfect on Windows 32-bit and Linux 32-bit
but I get only the half FPS rates with Linux 64-bit and Windows 64-bit !

I can use 3 or more cameras at once here on Linux but not on Windows

Joshy
MDN wrote:Remarks
Connecting a capture driver to a capture window automatically disconnects any previously connected capture driver.
Last edited by D.J.Peters on Jan 15, 2017 13:39, edited 1 time in total.
BasicCoder2
Posts: 3904
Joined: Jan 01, 2009 7:03
Location: Australia

Re: fbvideoclass (Windows 32/64-bit)

Post by BasicCoder2 »

Do the cams have to be plugged in? WIth only the integrated camera the software stops as it can't find the other cams whereas with the escapi version the software returns the number of cams and can displays each one in its own frame. The code below saves an image when the space bar is pressed.

Code: Select all

#include "escapi.bi"


Const iWIDTH = 320
Const iHEIGHT = 240

ScreenRes 640,480,32

Dim As Integer nDevices=setupESCAPI()

If nDevices<1 Then
    Print "No active capture device found!"
    Beep:Sleep:End
Else
    if nDevices > 4 then
        nDevices = 4
    end if    
    print "number of devices=";nDevices
End If

'list of pointers
Dim shared As Any Ptr lpImage(4)

for k as integer = 0 to nDevices-1
    lpImage(k)=ImageCreate(iWIDTH,iHEIGHT)
next k

Dim Shared As SimpleCapParams Params(4)

for k as integer = 0 to nDevices-1
  Params(k).mWidth  = iWIDTH
  Params(k).mHeight = iHEIGHT
  Params(k).mTargetBuf=cptr(Integer Ptr,lpImage(k))
  Params(k).mTargetBuf+=8
  doCapture(k)
next k

for k as integer = 0 to nDevices-1
    initCapture(k, @Params(k))
next k

dim as string key,fileName
dim as integer count
'main loop
dim as integer x,y
do
    for k as integer = 0 to nDevices-1
        doCapture(k)
        locate 1,1
        While isCaptureDone(k)<>1:Sleep(10):Wend
        if k = 0 or k = 2 then x = 0 else x = 320
        if k = 0 or k = 1 then y = 0 else y = 240
        Put (x,y),lpImage(k),Pset
    next k
    key = inkey
    if key=" " then
        fileName = "c:\FreeBasic\image"+str(count)+".bmp"
        bsave fileName,0
        count = count + 1
    end if
    
loop until multikey(&H01)


for k as integer = 0 to nDevices-1
    imageDestroy(lpImage(k))
next k

End
.
MrSwiss
Posts: 3910
Joined: Jun 02, 2013 9:27
Location: Switzerland

Re: fbvideoclass (Windows 32/64-bit)

Post by MrSwiss »

OK, fbvideoclass is now working on x64.

in "fbvideoclass.bi" two necessary changes made (before testing):

Code: Select all

Declare Sub GetStatus         (Byref s As CAPSTATUS)
Declare Sub GetParams         (Byref p As CAPTUREPARMS)
Declare Sub SetParams         (ByRef p As CAPTUREPARMS)  ' was ByVal
Declare Sub GetVideoFormat    (Byref v As BITMAPINFO)
Declare Sub SetVideoFormat    (ByRef v As BITMAPINFO)  ' was ByVal
' also in the implementations at:
' line # ca. 500 - 520
tests: ...01, 02, 03 are OK -- 04 NOK (blows at times) -- 05 and 06 are OK
D.J.Peters
Posts: 8586
Joined: May 28, 2005 3:28
Contact:

Re: fbvideoclass (Windows 32/64-bit)

Post by D.J.Peters »

Thank you for the testing.

@BasicCoder2 you know ?

fbvideoclass supports WDM (windows driver model) video capture controller drivers only.

escapi (easy simple capture API) supports DS (direct show) driver devices also.

some cameras, tv-cards or video grabbers comes with both a WDM and DS driver.

All my cams and TV cards are supported by Windows XP and the linux kernel drivers V4L2 (Video for Linux version 2)

but on my Windows 10 (64-bit) I don't get a working driver for older devices:

SN9C103 web cam with microphone

AIPTEK DV3300 camcorder.

...

Joshy
MrSwiss
Posts: 3910
Joined: Jun 02, 2013 9:27
Location: Switzerland

Re: fbvideoclass (Windows 32/64-bit)

Post by MrSwiss »

@Joshy,

you've been talking about "slowdown" on x64. Maybe all those Integers (I'd try Long).
I'm thinking about the CPU's cache, which is now mostly filled with useless ZERO's.

Just an idea ...
D.J.Peters
Posts: 8586
Joined: May 28, 2005 3:28
Contact:

Re: fbvideoclass (Windows 32/64-bit)

Post by D.J.Peters »

First step of my 3D printer/scaner thing :-)

I added a tiny USB camera and two cheap line lasers provisional via a hair rubber band to the 3D printer.

click to enlarge:
Image

Before I added a single cross laser but with two line lasers
I can enable and/or disable the vertical or horizontal lines separately.
(via FreeBASIC and the LPT port)

click to enlarge:
Image

The trick are I use a low resolution of 320x240 or 160x120 pixels for the video capturing.
The point are in this rough grid of pixels the laser lines are only one pixel height/width

This are one of the small captured frame click to enlarge:
Image
and with the stepper motors I can move the camera and lasers in fine steps of 0.01 mm in all 3 axis.
(via FreeBASIC and G-CODE over serial USB port)

Next step I have to replace the provisional rubber band with a well designed holder
for the camera and lasers and print it out via the 3D printer.

Joshy

In real the lines are really thin but my fotocamera does not like the laser light and the image are out of focus = blurry.

click to enlarge:
Image
Last edited by D.J.Peters on Sep 25, 2017 21:22, edited 1 time in total.
BasicCoder2
Posts: 3904
Joined: Jan 01, 2009 7:03
Location: Australia

Re: fbvideoclass (Windows 32/64-bit)

Post by BasicCoder2 »

At first I thought perhaps you were going to write a program to stitch together many images taken as the item is rotated to create a cloud of points.
It seems to me that home 3D printers are really only at the same stage as the first computer kits.
They need to handle many different materials and in the case of plastic items be able to mix plastics of different colors.
The ultimate 3D printer would lay down actual atoms or molecules of whatever type is required.
.
grindstone
Posts: 862
Joined: May 05, 2015 5:35
Location: Germany

Re: fbvideoclass (Windows 32/64-bit)

Post by grindstone »

D.J.Peters wrote:In real the lines are really thin but my fotocamera does not like the laser light and the image are out of focus = blurry.
The laser light seems to be too intense. Maybe it could help to put an aperture (~ 0.3 - 0.5 mm diameter) between the laser diode and the diffusing lens to make the laser beam darker (and thinner).
Stonemonkey
Posts: 649
Joined: Jun 09, 2005 0:08

Re: fbvideoclass (Windows 32/64-bit)

Post by Stonemonkey »

Hi Joshy, just come across this and there's something I'm wanting to try. There's someone called Johnny Lee on youtube with a video on headtracking using the wii camera and remote, if you've not seen it then check it out to see what im talking about.

I'm wanting to try something similar, I have a USB 3D camera that's meant to plug into phones but I've plugged it into my PC and it recognises it as 2 devices, so it's 2 cameras each at 720p. I also have a passive 3D TV which I use as my monitor and have done some stereoscopic rendering, what I'm thinking about trying is to fix a couple of LEDs onto the 3D glasses and do the stereoscopic rendering with headtracking using the 3D camera.

Is it possible to get the streams from 2 cameras into buffers quickly enough and at a decent framerate for that? I don't care about any processing of the image as long as i can detect the positions of the LEDs in the image in a dimly lit room.

EDIT: just been trying out the im_capture.dll but can't seem to get it working on 64 bit windows.
D.J.Peters
Posts: 8586
Joined: May 28, 2005 3:28
Contact:

Re: fbvideoclass (Windows 32/64-bit)

Post by D.J.Peters »

@Stonemonkey "im_capture.dll" is a 32-bit dll do you compiled a 32-bit exe on 64 bit windows ?

May be you have to use "libvlc" to handle two direct show streams with 64-bit FreeBASIC !

Joshy
Last edited by D.J.Peters on Jan 15, 2020 15:41, edited 2 times in total.
Post Reply