Today's Head Scratcher - Pan/Tilt IP Camera Control

Discussion in 'C-Bus Wired Hardware' started by Roosta, Oct 10, 2012.

  1. Roosta

    Roosta

    Joined:
    Nov 22, 2011
    Messages:
    560
    Likes Received:
    1
    Location:
    Australia
    Hello fellow CBUS Lovers,

    I have a real head scratcher and am wondering if it is even possible..

    Situation - Pan/Tilt IP Camera (QC-3834 http://www.jaycar.com.au/productView.asp?ID=QC3834&keywords=WIFIIPCAM&form=KEYWORD) that I am currently playing with.. I am wondering if there is any way to be able to control the pan/tilt functionality from CBUS.. No it doesnt have IR, or any physical method of control aside from LAN and web browser interface, which is ActiveX based.. I have viewed the source code of the webcams browser ui and the best I can get out of it is:

    Is it possible to do anything with this code and fire it out of a Wiser, PAC or C-Touch utilising logic? Or am i just in dream land..

    Cheers..
     
    Last edited by a moderator: Oct 10, 2012
    Roosta, Oct 10, 2012
    #1
  2. Roosta

    jboer

    Joined:
    Apr 27, 2012
    Messages:
    458
    Likes Received:
    35
    Location:
    Sydney
    For sure

    Hey

    You should be able to send P&T commands from a CTC as it supports HTTP manipulation. I am have not done heaps with HTTP in CBus logic, but all you need to do is send http strings to your camera. Maybe someone else can help with that.
    I am pretty sure that one from jaycar is a Foscam or at least a Foscam rip off so a string like this should work: (Put these into your browser and see if your cam moves!):

    Code:
    Left: http://CAMERAIP:PORT/decoder_control.cgi?command=4&user=USERNAME&pwd=PASSWORD
    
    Right: http://CAMERAIP:PORT/decoder_control.cgi?command=6&user=USERNAME&pwd=PASSWORD
    
    Stop: http://CAMERAIP:PORT/decoder_control.cgi?command=1&user=USERNAME&pwd=PASSWORD
    Obviously you will have to swap out the caps for the details of your camera. Playing around with the command numbers will give you your actions. You should be able to get up,down,left,right,stop and the 4 diagonals. You also will need to send the stop string to stop.

    Hope this helps.

    J
     
    jboer, Oct 10, 2012
    #2
  3. Roosta

    Roosta

    Joined:
    Nov 22, 2011
    Messages:
    560
    Likes Received:
    1
    Location:
    Australia
    Oh my god you are good J.. Thanks heaps..

    Wanna give a fella a hint how you found that one out and so quickly?

    PS Typing command as you have given works a treat..

    Cheers,
    Nik
     
    Roosta, Oct 10, 2012
    #3
  4. Roosta

    jboer

    Joined:
    Apr 27, 2012
    Messages:
    458
    Likes Received:
    35
    Location:
    Sydney
    A lot of time playing with IP cameras and different control methods :)

    this page can be a good help too: http://www.zoneminder.com/wiki/index.php/Foscam

    As you can see you can send strings to change pretty much every single function you can set from the web UI. Including the LED on the front :)

    Something I didn't see before is the list of command numbers and their functions. I was looking for that last night, but elsewhere.

    Hope you have fun with it and feel free to PM if you have any other cam questions :)

    J
     
    jboer, Oct 11, 2012
    #4
  5. Roosta

    Roosta

    Joined:
    Nov 22, 2011
    Messages:
    560
    Likes Received:
    1
    Location:
    Australia
    Thanks again mate..

    Now a super good one for the gurus.. I spent a bit of time reading up on various logic functions and have written a bit of code below but unfortunately it is not working..

    The logic is running as the cbus functions as expected, but IP Camera is still..

    Can anyone tell me if i am on the right track? Hints or ideas?

    Cheers..
     
    Roosta, Oct 11, 2012
    #5
  6. Roosta

    jboer

    Joined:
    Apr 27, 2012
    Messages:
    458
    Likes Received:
    35
    Location:
    Sydney
    Try this

    This is what I had in my head that would work because you dont really want to have a socket connection with the camera:


    Code:
    once (GetLightingState("Group 0") = ON) then
    Begin
    PostHTTPData('http://IP:PORT/decoder_control.cgi?command=4&user=admin&pwd=',''); {Command to start left camera movement}
    Delay("0:00:01");
    PostHTTPData('http://IP:PORT/decoder_control.cgi?command=1&user=admin&pwd=',''); {Command to stop camera movement}
    SetLightingState("Group 0", OFF);
    End
    PS. It does work, just tested it with my camera and PICED... :)
     
    Last edited by a moderator: Oct 11, 2012
    jboer, Oct 11, 2012
    #6
  7. Roosta

    Roosta

    Joined:
    Nov 22, 2011
    Messages:
    560
    Likes Received:
    1
    Location:
    Australia
    Thanks again J.. You are truely a Guru.

    I actually had this same function already written up but ran into an issue where the PostHTTPData function is not supported in wisers logic engine.. So opted to go down the Clientsocket path.. Its a pity.. There goes that idea..

    Many thanks again.. :)

    Cheers..
     
    Roosta, Oct 11, 2012
    #7
  8. Roosta

    jboer

    Joined:
    Apr 27, 2012
    Messages:
    458
    Likes Received:
    35
    Location:
    Sydney
    Ah yes :-( That is a bit of a shame.

    If you don't have a CTC, the only other option I could think of then is to have a third party device (PC) that you can have a socket/serial connection with and that then sends your commands..
     
    jboer, Oct 11, 2012
    #8
  9. Roosta

    Mr Mark

    Joined:
    Jan 27, 2006
    Messages:
    323
    Likes Received:
    5
    Location:
    FNQ
    Moving forward

    First of all, thanks for the information posted above as it helped a great deal!

    After much testing I got the following to work on my Foscam copy camera:
    Code:
    once
      (GetLightingState("_CAM_LEFT") = ON) then
    begin
      PostHTTPData('http://IP_ADDRESS/decoder_control.cgi?command=4&user=<USER>&pwd=<PASSWORD>', '');
    end;
    
    All good so far.

    Now, back to the client. This code below works on a LILIN Fastdome(?):
    Code:
    once
      (GetLightingState("_CR_LEFT") = ON) then
    begin
      PostHTTPData('http://IP_ADDRESS/control?camid=1&rpan=-2', '');
    end;
    
    Marvellous! This camera was a replacement for a Vivotek PZ6112.

    The other two cameras on site are Vivoteks also and here's my problem - the code below doesn't work. When we put the HTTP data straight into a web browser it does
    Code:
    once
      (GetLightingState("_CRP_LEFT") = ON) then
    begin
      PostHTTPData('http://IP_ADDRESS/cgi-bin/camctrl.cgi?move=left', '');
    end;
    
    In each case IP_ADDRESS is an actual address...
    Any ideas as I would like to keep the 'feel' of the control the same across the project. Initially this will be running on HomeGate but hope to migrate to the touch screen using sub-pages for pan/tilt control..
     
    Mr Mark, Oct 12, 2012
    #9
  10. Roosta

    jboer

    Joined:
    Apr 27, 2012
    Messages:
    458
    Likes Received:
    35
    Location:
    Sydney
    I would probably Wireshark your network and see if, Homegate actually sending anything and if so what the differences are in the packets from Homegate and a web browser.

    J
     
    jboer, Oct 12, 2012
    #10
  11. Roosta

    jboer

    Joined:
    Apr 27, 2012
    Messages:
    458
    Likes Received:
    35
    Location:
    Sydney
    So after a bit of research you can have a socket connection with a foscam camera but as usual the hitch is that you need to load some 'spicy' firmware that various people have worked on. If you want to look at this PM me and I can send you some more stuff.

    J
     
    jboer, Oct 12, 2012
    #11
  12. Roosta

    kjayakumar

    Joined:
    Oct 27, 2008
    Messages:
    448
    Likes Received:
    0
    I'll get an issue filed. PostHTTPData/other http functions in Wiser should be feasible.
     
    kjayakumar, Oct 12, 2012
    #12
  13. Roosta

    Mr Mark

    Joined:
    Jan 27, 2006
    Messages:
    323
    Likes Received:
    5
    Location:
    FNQ
    Hello jboer.
    I've been resisting learning Wireshark for a while now (not enough time), but looks like this weekend is the time...
     
    Mr Mark, Oct 12, 2012
    #13
  14. Roosta

    Roosta

    Joined:
    Nov 22, 2011
    Messages:
    560
    Likes Received:
    1
    Location:
    Australia
    Hmm.. 'Spicy' you say.. This does make me a little hesitant.. Ha Ha.. Maybe though.. Thanks again for your efforts J..

    Hey Kjayakumar.. I totally agree.. Let us know what everyone else says.. :-D

    Cheers..
     
    Roosta, Oct 12, 2012
    #14
  15. Roosta

    jboer

    Joined:
    Apr 27, 2012
    Messages:
    458
    Likes Received:
    35
    Location:
    Sydney
    Hey,


    Just a thought after looking at the manual it wouldn't surprise me if you need some sort of auth. I would try something like:
    Code:
    http://USER:PASSWORD@IP_ADDRESS/cgi-bin/camctrl.cgi?move=left
    When you are using it on your browser if you have already accessed the camera recently the camera will remember your login or if you have selected remember login details will just do it automatically when it asks for it.

    Even if you have no password you still may need to give it a user account.

    J
     
    jboer, Oct 13, 2012
    #15
  16. Roosta

    jboer

    Joined:
    Apr 27, 2012
    Messages:
    458
    Likes Received:
    35
    Location:
    Sydney
    Sorry for the double post

    Mr Mark, I have just had some time to do a Wireshark myself between PICED and Firefox and I think the following may work a bit better. That webcam may not like a POST command, I hadn't really thought about it before but a GET command is probably better all round.

    Code:
    once
      (GetLightingState("_CRP_LEFT") = ON) then
    begin
      GetHTTPData('http://IP_ADDRESS/cgi-bin/camctrl.cgi?move=left');
    end;
    Hopefully between the 2 posts something may be able to help!

    J
     
    jboer, Oct 13, 2012
    #16
  17. Roosta

    Mr Mark

    Joined:
    Jan 27, 2006
    Messages:
    323
    Likes Received:
    5
    Location:
    FNQ
    Success

    Hello J.

    The foscam and LILIN camera's both accepted the Post HTTPData commands and your suggestion of GetHTTPData was bang on the money!
    I'll implement this fix next week for another happy customer.

    Mark
     
    Mr Mark, Oct 14, 2012
    #17
  18. Roosta

    jboer

    Joined:
    Apr 27, 2012
    Messages:
    458
    Likes Received:
    35
    Location:
    Sydney
    That would be great! Would it also be possible to get some more of the Email procedures in the Wiser as well? Such as GetEMailBodyLine?
     
    jboer, Oct 14, 2012
    #18
  19. Roosta

    Roosta

    Joined:
    Nov 22, 2011
    Messages:
    560
    Likes Received:
    1
    Location:
    Australia
    Hey J,

    Anothe quick one maybe.. Just been mulling on what windows this all opens up.. Are you away of any command that we can shoot out as a url string to change resolution??

    Situation: Customer has IP cams and C-BUS C-touch Colour and Wiser.. Currently have the IP Cams set for highest resolution possible, 640x480, but unfortunately when a put onto the c-touch it is to big an image for the screen and given scroll bars, which is not ideal.. If resolution gets set lower it fits lovely on the screen..

    Thinking if i had some logic so when camera page was selected or doorbell rang that would temporarily change the video resolution to a lower setting then time out and set it back to high..

    Whats your thoughts?

    Cheers..
     
    Roosta, Oct 15, 2012
    #19
  20. Roosta

    Mr Mark

    Joined:
    Jan 27, 2006
    Messages:
    323
    Likes Received:
    5
    Location:
    FNQ
    Resolution

    Hello Roosta

    I found some documentation last night and this may help:

    Description:ip camera send the JPEG video streaming to client by server push model.
    Authorization:Visitors
    Grammar:/videostream.cgi[?user=&pwd=&resolution=]
    parameters:
    resolution:Image resolution(8:320*240,32:640*480)

    I haven't tried it yet but it appears something along the lines of http://IP_ADDRESS/videostream.cgi?user=USER&pwd=PASS&resolution=8 or http://IP_ADDRESS/videostream.cgi?user=USER&pwd=PASS&resolution=32 should do what you want.

    Mark
     
    Mr Mark, Oct 15, 2012
    #20
Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.