vb.net - Capture frames from IP camera using EmguCV -
maybe title has been used lot of times, answer found on google gives me correct answer, i'm going explain problem here:
i have ip camera, works using it's own program, know camera works fine. have set ip camera have static ip, has same ip address. succeed taking frames webcam, using:
dim image image(of bgr, byte) = capturez.queryframe()
and know method queryframe() has 3 ways of use:
dim image image(of bgr, byte) = capturez.queryframe() dim image image(of bgr, byte) = capturez.queryframe(int) dim image image(of bgr, byte) = capturez.queryframe(string)
i trying this:
dim image image(of bgr, byte) = capturez.queryframe("rtsp://192.168.1.3/img/video.sav")
many people works, not me. i've seen in other forums this:
dim image image(of bgr, byte) = capturez.queryframe("rtsp://user:pass@192.168.1.3/img/video.sav")
in case ip camera has user , password attached (which case), still doesn't work.
the error is: 'a value type emgu.cv.image(of emgu.cv.structure.gray, byte) can not converted in emgu.cv.image(of emgu.cv.image(of emgu.cv.structure.bgr, byte)'
i dont know why error. think because capture.queryframe() taking capture type emgu.cv.structure.gray , can not converted other one, have not idea if right.
if right, dont know how save image taken capture.queryframe()
if i'm not right, don't know why getting error.
i have seen other people using things this:
dim image image(of bgr, byte) = capturez.queryframe("http://192.168.1.3:port/img/video.sav")
but ip camera not connected internet. connected lan, directly computer. have configured ipv4 config of computer, , settings of ip camera, make works without internet connection, , said before, working using own program.
i hope have details needed make understand problem. if not, please tell me , try explain in way.
resuming: have ip camera, want take picture (not video streaming, picture when decide it), using emgu 2.4.0, visual basic , vs2012. don't know how using queryframe() method
to finish, if possible, tell me means
../img/video.sav
that put in string? directory must have in computer or this?
i put method trying capture if help. in trying capture frame , display in picturebox white colours of image in white, , rest in black:
private sub startbuttontimer_tick() handles startbuttontimer.tick dim x integer dim y integer if timeleft > 0 timeleft -= 1 timelabel.text = timeleft & " seconds" 'dle prueba tomar foto después del tiempo especificado - pongo negro el fondo del picturebox picturebox1.backcolor = color.black else 'dle prueba tomar foto después del tiempo especificado - hago foto de lo que ve la camara dim img image(of bgr, byte) = capturez.queryframe() x = 0 img.width - 1 y = 0 img.height - 1 dim pixelcolor bgr = img(y, x) if (pixelcolor.blue >= 200 , pixelcolor.blue <= 255) , (pixelcolor.green >= 200 , pixelcolor.green <= 255) , (pixelcolor.red >= 200 , pixelcolor.red <= 255) pixelcolor.blue = 255 pixelcolor.green = 255 pixelcolor.red = 255 img(y, x) = pixelcolor else pixelcolor.blue = 0 pixelcolor.green = 0 pixelcolor.red = 0 img(y, x) = pixelcolor end if next next startbuttontimer.stop() picturebox1.image = img.tobitmap startbutton.enabled = true setparameters.enabled = true setdefaulttimebutton.enabled = true setform() end if 'old frame overwritten current image ready retrieve dim image image(of bgr, byte) = capturez.queryframe() end sub
thanks lot help!! getting crazy this!!
edit: researching little bit in aforge libraries , forums, have seen thisthread, guy explains how take images ip camera using libraries. have libraries installed in computer other projects, didn't know use libraries purpose.
this thread: http://emgu.com/forum/viewtopic.php?t=4199
i went there , have seen projects suggest see, , have found in samples directory, project called player, use method open url of camera display watching:
// open mjpeg url private void openmjpegurltoolstripmenuitem_click( object sender, eventargs e ) { urlform form = new urlform( ); form.description = "enter url of mjpeg video stream:"; form.urls = new string[] { "http://195.243.185.195/axis-cgi/mjpg/video.cgi?camera=4", "http://195.243.185.195/axis-cgi/mjpg/video.cgi?camera=3", }; if ( form.showdialog( ) == dialogresult.ok ) { // create video source mjpegstream mjpegsource = new mjpegstream( form.url ); // open openvideosource( mjpegsource ); } }
i studying how works, don't understand why use lines in way:
"http://195.243.185.195/axis-cgi/mjpg/video.cgi?camera=4", "http://195.243.185.195/axis-cgi/mjpg/video.cgi?camera=3",
i mean, know have put url of camera, in url of example. in case, ip camera 192.168.1.3, must this:
"http://192.168.1.3/axis-cgi/mjpg/video.cgi?camera=4"
but, rest of line, mean, this:
.../axis-cgi/mjpg/video.cgi?camera=4
why put this? don't know how find information in camera. have 1 camera connected via ip so, must put there? directory have create or that?
edit: above, after investigate little more have seen rest of url specifies path image store. after trying find path camera leaves images, not able find it, nor user's guide, nor surfing internet. not able find path =(. has idea how find it?
thanks lot!!
tools using: emgucv 2.4.0, vs2012, ip camera: etrovision ev6131hw, visual basic
last edit - solution: hi everyone! solution al questions, post here if see useful.
about first question, ask url inside of method queryframe():
dim image image(of bgr, byte) = capturez.queryframe("rtsp://192.168.1.3/img/video.sav")
i have read lot , conclusion url specified manufacturer, specified in datasheet of camera, neither invented url, nor folder image stored. see example, can see in url below, of urls used different cameras:
so, writting specifid url of camera inside of declaration of variable, must enough achieve connection camera. achieve using axis camera, checking datasheet. in case, url:
dim capturez capture capturez = new capture("rtsp://192.168.0.90/axis-media/media.amp?videocodec=h264")
for next question did:
if right, dont know how save image taken capture.queryframe()
it easy. image returned queryframe method, must stored in variable of type image, this:
dim img image(of bgr, byte) = capturez.queryframe picturebox1.image = img.tobitmap() 'if want store image of picturebox picturebox1.image.save("f:\picture.bmp") 'if want store image stored in variable img imagetoprocess.save("f:\picture.bmp")
the file stored, must have extension .bmp, because storing bitmap image (i not sure @ if can confirm, edit if needed)
about said here:
but ip camera not connected internet. connected lan, directly computer. have configured ipv4 config of computer, , settings of ip camera, make works without internet connection, , said before, working using own program.
it not necessary have camera or computer connected internet achieve this. can using internet, of course, if have camera connected in same network of computer, or connected directly ethernet cable no using switch or router, enough changing ip address of computer or ip address of camera have them working in same network (in case of computer, using static ip). example:
ip address pc: 192.168.0.2 ip address camera: 192.168.0.3
you can change ip address of camera in settings using software provided manufacturer, , ip address of computer going network , sharing center of pc.
about next question:
to finish, if possible, tell me means that
../img/video.sav
this answered above, explained line part of url provided manufacturer.
about asked here:
i went there , have seen projects suggest see, , have found in samples directory, project called player, use method open url of camera display watching:
i didn't need finally, code shown there useful if has more 1 camera, using url:
"http://195.243.185.195/axis-cgi/mjpg/video.cgi?camera=4", "http://195.243.185.195/axis-cgi/mjpg/video.cgi?camera=3"
in part:
?camera=3
you specifying camera going use. rest of string, url provided manufacturer.
i hope someone, have spent lot of time in , proud it, if has question, , couldbe useful, don't hesitate ask me in thread or direct message.
thanks everyone!
Comments
Post a Comment