Canon VC-C4 User manual
Remote Camera Controller
Implemented on the Canon VC-C4
Numerisk analys och datalogi
100 44 Stockholm
Department of Numerical Analysis and Computer Science
Royal Institute of Technology
SE-100 44 Stockholm, Sweden
Remote Camera Controller
Implemented on the Canon VC-C4
Bachelor’s Thesis in Computer Science (10 credits)
Single Subject Courses,
Stockholm University 2005
Supervisor at Nada was Alex Jonsson
Examiner was Stefan Arnborg
This thesis presents the design and implementation of a remote camera controlling application for Canon VC-C4 and VC-C4R, The application is implemented in low level programming language for MS Windows 95 and above.
The project consists of two programs, a Client and a Server.
Remote VCC4 uses a simple interface on both Client and Server. The enduser can control the camera from a remote computer, change focus, zoom, ﬂicker, speed et cetera.
95 och senare.
zoom, ﬂimmer, hastighet osv.
DEDICATED TO MY BELOVED FAMILY
I would like to thank my teachers for helping me achieve what I have achieved, also I like to thank the Staﬀ at KTH, NADA(The Royal Institute of Technology, Department of Numerical Analysis and Computer Science) for helping me out with my project and for being so kind and patient.
Special thanks goes to Mr. Mats Erixson at KTH, AMT(Advanced Media
Technology) and Dr. Alex Jonsson at KTH, GT (Graphic Arts Technology and Management).
Organization of the Master’s thesis
Is a basic description of the problem at hand, followed by an outline of the solution to be implemented.
Is about the planning phase and a review of tools, on which this project will be implemented.
Is the heart of the thesis, where the implementation method is carried out, and where the user interface is decided. In a nutshell this chapter is about the implementation in detail.
Is the testing phase, where test equipment is presented and test results are given.
Is a conclusion of the whole project.
1 Introduction 1
Description of the problem . . . . . . . . . . . . . . . . . . . .
Overview of the client . . . . . . . . . . . . . . . . . . . . . .
Overview of the server . . . . . . . . . . . . . . . . . . . . . .
2 Planning phase 4
Tools . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Compiler MASM32 . . . . . . . . . . . . . . . . . . . .
IDE RADasm . . . . . . . . . . . . . . . . . . . . . . .
3 Implementation phase 8
TCP/IP . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Serial port . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Server . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Client . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
4 Test phase 14
Appendix: Control Command Tables 17
Pedestal Control Command Table . . . . . . . . . . . . . . . . . .
Camera Control Command Table . . . . . . . . . . . . . . . . . . .
System control Command Table . . . . . . . . . . . . . . . . . . .
The idea is to control a camera connected to a computer serial port, from a remote client computer, connected via any IP based network.
The hardware equipment are a Canon VC-C4/VC-C4R Camera, a PC acting as server and another one acting as client, see ﬁgure 1.
The VC-C4 is a desktop camera, while VC-C4R is a reverse model suited for ceiling mount. Both cameras have the ability to connect to a computer via serial port. The VC-C4 and VC-C4R handles a set of commands received by the serial port, through which we can control pan, tilt, zoom and more, see ﬁgure 2. A list of all available commands are described in the appendix.
Figure 1: Connection schema.
Description of the problem
The aim of the project is to control the Camera in real time, in other words the application is time-critical, so we have to look into the factors that are time consuming. We can easily locate time-critical parts of the application into three diﬀerent parts, serial communication, network latency and data processing. Serial communication is limited by hardware and the amount of data sent to an received from the camera is pre-programmed by the manufacturer, so there is not much we can do about it.
Figure 2: Tilt and Pan.
Overview of the client
The network-latency depends on distance and speed, outside the LAN (Local Area Network), IP packets travel through gateways and routers on the
Internet, which introduce transit delays, by reducing the amount of data, we can reduce overall latency. Now the last part which is data processing depends fully on the algorithms in our application, we have to use fast algorithms and process as little data as possible.
The client application can be implemented in any programming language, as long as it communicates using TCP/IP. A Friendly user-interface makes it easy for the user to navigate, and attaching a joystick, steering pad or any input device is no problem at all.
Following is the client list of functions:
Connect to server
Disconnect from server
Release resources and Exit
Show About dialog box
Tilt and pan north east
Tilt and pan north west
South west Button
Tilt and pan to south east
Tilt and pan to south west
Zoom in and out
Set manual focus
Auto Focus Check box Set auto focus
Save Check box Save camera position
Disp. Time Button
Nine saved positions
Activate remote control
Turn camera on and oﬀ
Edit box Server IP address
Edit box Set network port
We also have three command groups placed in boxes, to control exposure and white balance:
Black light adjust
Check box Auto adjust light
Slider Adjust brightness in AE mode
Check box Flicker less AE see appendix 1
Auto White Balance Check box Set Auto white balance
White Balance Slider Adjust white balance
Overview of the server
The Interface of our server is less sophisticated, in fact the user has only two options, either the server is running and the user has the option to stop it, or the server is not running and the user can start it by pressing the (Run
Server ) button.
For security reason the server can be set to accept only one particular IPaddress, the computer with this IP then will be the only one allowed to send control commands to the server. We also bind it to a speciﬁc network port of our choice.
The Server can only connect one client at a time, if one client is connected the next connection will be rejected. On the other hand sending control signals to the server from two diﬀerent clients simultaneously is not what we want to achieve, this will only lead to unpredictable results.
Following is the server list of functions:
Command Type Description
Run Server Button initialize network
Disconnect Button Disconnect and release resources
IP address Edit box Client IP address
Edit box Set network port
2 Planning phase
The project goal is to be able to control a camera in real time, thus the loss of any performance will result in the loss of the desired eﬀect. Therefor we have to be careful in choosing the proper tools and using them in the right way.
First we start by looking at some programs addressing similar problem, one of these programs is VCC4VCSample. The drawback of this program is that it did not implement most of the camera features, the user-interface has only nine buttons to control directions and power on/oﬀ. The second drawback is that it has no network support, in other words you can not control the camera remotely.
Another program is VCC4CONT. This one is much better than the previous mentioned one, it has a nice user-interface and more features of the camera is used, but unfortunately still no network support.
Next step is to gather all the information about technical parts involved in the project, and choose the most suitable solutions for it.
In my search I found out the following :
1. We have to use communication with the camera via a serial port, that is the way this camera is intended to be used see ﬁgure 3. A serial port
Figure 3: Connection schema.
is an interface, with which information is transferred in or out one bit at a time, this is accomplished using the RS-232 standard over simple cables connecting the computer to a device.
The three most important abbreviations are, CTS (Clear To Send),
TxD (Transmitted Data),RxD (Received Data) and GND (Ground).
2. In choosing the Internet Protocol I did not have the same limitation as in choosing an Interface to the camera, in this case the camera had no knowledge where the commands were coming from. I evaluated two diﬀerent protocols namely TCP (Transmission Control Protocol) and
UDP (User Datagram Protocol), at the end I chose TCP/IP for the following reasons:
With only 4 header ﬁelds of which two are optional, UDP provides a faster transfer of data. UDP provides no error recovery, for this reason it is sometimes expanded to Unreliable Datagram Protocol. UDP applications must generally be willing to accept some loss, errors or duplication. UDP is connectionless, it means that a datagram can be sent at any moment without prior advertising, negotiation or preparation. Just send the datagram and hope the receiver is able to handle it.
On the other hand being connection-oriented with TCP means that before actually transmitting data, you must open the connection between the two end points. The data can be transferred in full duplex
(send and receive on a single connection). When the transfer is done, you have to close the connection to free up system resources. Both ends know when the session is opened (begin) and is closed (end). The data transfer cannot take place before both ends have negotiated the connection. The connection can be closed by either side; the other side is notiﬁed. Provision is made to either close gracefully or just to abort the connection.
In choosing the development tools, we have to take in to consideration the availability of documentation, because when we need help the more popular tool we choose, the easer it is to get help, from mailing lists, web sites, books and examples.
The second issue to consider in choosing our tool is the tool’s ability to help us achieve our goal.
With these points in mind, I began my searching for the proper tools, by comparing diﬀerent assemblers and found MASM32 (Microsoft assembler) to be the most common implementation, it has been used since the 1980’s and has so many enthusiasts around the world.
When it came to the IDE(Integrated Development Environment) it did not make any diﬀerence, because the project is not dependent on the it, meaning that it could be replaced in mid-project without eﬀecting project functionality. So I decided to use RADasm, because it has code highlighting for
MASM32 and visual resource editor to build a user-interface.
MASM32 is an assembler developed by Microsoft easy to use, with support for some high level structure, like if-, while-statements et cetera.
Since MASM32 is a 32 bit compiler it supports windows programming, hence a programmer can invoke or call a windows routine.
The compiler includes a 32 bit linker(link) and a resource compiler (rc), to help build the ﬁnal application.
A typical make ﬁle could look like this:
@echo off if exist #1.obj del #1.obj
if exist #2.rc del #2.rc
\backslash masm32\backslash bin\backslash ml /c /coff #1.asm
if errorlevel 1 goto error1
\backslash masm32\backslash bin\backslash rc /c /coff #2.asm
if errorlevel 1 goto error2
\backslash masm32\backslash bin\backslash Link /SUBSYSTEM:WINDOWS #1.obj #2.obj
if errorlevel 1 goto error3 goto next
echo error in creating resource file goto next
:error2 echo error in assembling source file
:error3 echo error in linking the object files
RADasm is an Editor with support for highlight of code and indentation, it also has a very nice visual resource editor to help build the user-interface, se ﬁgure 4.
RADasm has many features like building a project ﬁle for all the diﬀerent code ﬁles involved in a project, it also hooks to a compiler to build and run the program from with in the IDE.
Figure 4: Connection schema.
3 Implementation phase
In our implementation we build every part as a unit, and then connect all units together.
First we built a small network consisting of two computers, the ﬁrst computer would be our server, where the target camera is connected to. The second computer is a client, which will request the connection.
TCP/IP protocol is connection-oriented between two sides, each has its own
IP and port number. One side is called the server, the other side the client.
We use Winsock (Windows Sockets) in the Windows API (Application Programming Interface) that deals with networking. A socket is our handle to a connection, both client and server has a handle to a connection. A socket is a two-way connection, and they are not platform-speciﬁc, that is how a
Windows and a Unix machine can communicate with each other.
In our project we use the API function bind to bind a socket in our server to a speciﬁc IP and port, a combination of bind IP and port by the server is the only one granted connection, se ﬁgure 5.
Figure 5: Bind IP and port.
The following code sample shows how to create a connection to the server:
; pSockAddr pointer to the sockaddr_in structure to fill
; portNumber server port number
; Return value
SetServerSockAddr proc pSockAddr:dword, portNumber:dword mov edx, [pSockAddr] mov ecx, [portNumber] xchg cl, ch ; convert to network byte order mov [edx][sockaddr_in.sin_family], AF_INET mov [edx][sockaddr_in.sin_port], cx mov [edx][sockaddr_in.sin_addr.S_un.S_addr], INADDR_ANY ret
For serial communication we use API functions CreateFile, ReadFile and
WriteFile, they open a port as if it is a ﬁle, and gives us a handle to the buﬀert where we can send data to or receive data from. Data we place in the buﬀer using WriteFile will be received by the camera, and by using ReadFile we receive response.
The following code sample shows how the server connects to the camera:
OpenPort proc comX:dword invoke CreateFile,addr comX,GENERIC_READ or GENERIC_WRITE,0,0,OPEN_EXISTING,0,0 mov hcomm,eax
.IF eax==INVALID_HANDLE_VALUE mov eax,1 mov herror, offset g_SPErorr
By calling function CreateFile we recive a handel in hcomm, this handle can be used later communicate with the camera.
The following code sample shows how to read from and write to the camera:
WriteF proc invoke WriteFile,hcomm,addr Header,sizeof Header-1,addr n,NULL ret
ReadF proc invoke ReadFile,hcomm,addr data,sizeof data-1,addr n,NULL ret
The serial port converts each byte to a stream of ones and zeroes before sending and back again to byte when receiving data. An electronic chip called a UART (Universal Asynchronous Receiver/Transmitter) is actually the one that does the conversion.
The server application has a very simple interface, two buttons one for putting the server online and the other one for taking it of line, as well as two edit boxes to specify the IP address of the remote client and the port to be used, se ﬁgure 6.
When a user presses the Run server button, we check for the camera via serial port, if camera exist we initialize it by adjusting the head to be centered, then we start a new socket, the socket is bind to the IP and port numbers speciﬁed in the edit boxes, ﬁnally the program gets into a standby position, waiting for a client to connect. As soon as connection is request by a client, we verify the client IP and port used to connect , if the IP and port matches the one entered into the edit boxes, access is granted by the server and connection is established.
The server receives single character from the client, each character corresponds to a command that is recognized by the camera, the server then sends the command to the camera. After the command has been issued, the camera sends a veriﬁcation signal to the server.
Figure 6: Server.
Following code shows one sample out of 40 implemented commands:
.if al=="T" ; letter corresponding to command mov eax,0EF313260h ; command for pan right tilt down mov [esi+4],eax ; we put it in buffer invoke WriteF
; and send it to the serial buffer
The client program has a more complicated user-interface, to give the user control over as many functions as possible. The client program has nine direction buttons, for directional head movements, two sliders for adjusting zoom and focus, buttons to save nine diﬀerent positions, sliders to control light, brightness and some buttons for time and power, se ﬁgure 7.
When the User presses Connect from the menu, a connection request is sent to the server which IP address is in the edit box. If the server accepts the client IP, connection will be established and access to the device is granted by the server. Now the client program is ready to send commands to the camera.
Every command is saved as a single character in order to save band-width and to achieve a fast transfer rate. Pressing “Disconnect” or “Exit” will terminate the connection and give control back to the server, “Exit” will terminate the client application as well.
Figure 7: Client.
Following code sample shows how the decoding of commands is done: c_Power db "A",0 ;Define Char A to turn camera on and off c_Home db "H",0 ;Define Char H to position set position home c_UL db "T",0 ;Define Char T to move UP and LEFT
.if eax == B1 ; Is button B1 pressed?
mov eax,offset c_UL ; Bring the definition of command mov ebx, sizeof c_UL ; and the size invoke WriteData,eax,ebx ; send it to server
4 Test phase
I divided the whole project into small units, test was made in the same fashion, each and every module was tested individually.
First of all I wrote a small application to communicate with the camera, using serial port we send commands to and receiving response from the camera. After analyzing the results I found out that receiving response take more time then sending, so I decided to receive the response in a diﬀerent thread. This way I could cut the time spent by send and receive to less then half.
I moved next to the internet protocol, I wrote a small application that generated random data, then send it back and forth between two computers, and at the end the data is been analyzed by the application, analysis showed that looking for received data took more time then working with it, so I moved this part as well to a diﬀerent thread.
Both threads will notify the main thread when data is available, this way our main thread will have more time to work on data received.
I merged the two applications, after correcting some bugs I run the test a few more times, to compeer sent and received data.
From this point I began to build the ﬁnal application, of course I hade to optimize every module for speed and minimize the use of CPU and the size of data transfer.
Finally I run some more tests using my test applications, and more analysis of data is made to the ﬁnal application, at this point the program was ready and needed only a friendly user-interface.
After building the user-interface, test had to be done manually to all the components in both server user-interface and Client user-interface, and the application was ready to be used.
In building such a time critical application, we need to consider using a low level programming language.
In this project there are three time critical moments:
1. The serial communication with the camera.
2. The network communication.
3. The data encoding and decoding done by the application.
The Remote Camera Controller system can be useful where we need to monitor several geographically separated areas from one place, by placing a camera in every location and remotely controlling them. It can also be used to stream pictures from hazardous areas, like areas contaminated with toxic gas or high degree of pollution.
Janet L. Axelson
Serial Port Complete, lakeview research llc
Bob Quinn and Dave Shute
Windows Sockets Network Programming, Addison-Wesley.
Kip R. Irvine
Assembly Language for Intel-Based Computers 4th ed., Prentice-Hall Inc.
Programming Windows 5th ed., Microsoft Press
Forum For Assembler Language Programmers http://www.masmforum.com
Last visited 20 May 2005
The Microsoft Developer Network http://msdn.microsoft.com
Last visited 23 May 2005
Serial port (RS-232) Interfacing http://www.beyondlogic.org/index.html
Last visited 10 May 2005
Winsock Programmer’s FAQ http://tangentsoft.net/wskfaq
Last visited 1 April 2005
Appendix: Control Command Tables
Following tables describes all the commands for communicating with Canon
VC-C4 camera, via the serial port RS-232C interface:
Pedestal Control Command Table
Pan Speed Assignment
Tilt Speed Assignment
Pan Speed Request
Tilt Speed Request
Pan Tilt Stop
Pan Right Start
Pan Left Start
Tilt Up Start
Tilt Down Start
Pedestal Initialize 1
Pedestal Initialize 2
To set running speed for Pan
To set running speed for Tilt
To return present running speed for Pan
To return present running speed for Tilt
To stop running of Pan/Tilt
To start Pan running to right
To start Pan running to left
To start Tilt running to up
To start Tilt running to down
To move Home position
After Initialization, to move home position
After Initialized, to move the origin position
Pan Slowest Speed Request
Pan Fastest Speed Request
Tilt Slowest Speed request
Tilt Fastest Speed request
Pan Angle Pulse Ratio Request
Tilt Angle Pulse Ratio Request
Pan Minimum Angle Request
Pan Maximum Angle Request
To return the slowest speed of Pan
To return the fastest speed of Pan
To return the slowest speed for Tilt
To return the fastest speed for Tilt
To return coeﬃcient of Pan angle conversion
To return coeﬃcient of Tilt angle conversion
To return minimum angle of Pan
To return maximum angle of Pan
Tilt Minimum Angle Request
Tilt Maximum Angle Request
Pan/Tilt Start Stop
Pan/Tilt Angle Assignment
Pan/Tilt Angle Request
Pan Movable Range Assignment
Tilt Movable Range Assignment
Pan Movable Range Request
To return minimum angle of Tilt
To return maximum angle of Tilt
To stop Pan/tilt running
To start and stop Pan/tilt running
To move assign position of Pan/Tilt
To return present position of Pan/Tilt
To assign movable limit for Pan
To assign movable limit for Tilt
To return present position of Pan
Tilt Movable Range Request To return present position of Tilt
Note: XXXX, YYYY means Pan angel, Tilt angle In Hexadecimal
PMIN, PMAX means Pan min. movable range, max. movable range in Hexadecimal
TMIN, TMAX means Tilt mini. movable range, max. movable range in Hexadecimal
The value inside ( ) means status value in the inverse mount type
0h, PMIN, PMAX
1h, TMIN, TMAX
Camera Control Command Table
Focus Position Assignment
Focus Position Request
One Push AF
Focus Range Request
Zoom Hi Wide
Zoom Hi Tele
Zoom Position 1 Assignment
Zoom Position 1 Request
Zoom Position 2 Assignment
Zoom Position 2 Request
Zoom Speed Assignment
Zoom Speed Request
Zoom Maximum Request
Backlight Compensation OFF
Backlight Compensation ON
AE Lock OFF
AE Lock ON
Shutter Speed Program
Shutter Speed 1/60 (PAL: 1/50)
Shutter Speed1/100 (PAL: 1/120)
Shutter Speed Assignment
To turn OFF power for Camera section
To turn ON power for Camera section
To change mode of focus to AF
To stop and change of focus to Manual
To move to near focus
To move to far focus
To move to focus position assigned
To return present focus position
After adjustment of focus, change to AF
To return movable range of focus
To stop zoom operation
To zooming to wide
To zooming to tele
To zooming to wide high speed
To zooming to tele high speed
To move to zoom position assigned
To return present zoom position
To move to zoom position assigned
To return present zoom position
To assign running speed of zoom
To return present running speed
To return maximum movable position
To eliminate compensation of backlight
To compensate backlight
To control exposure automatically
To control exposure manually
To cancel AE lock ON
To lock the exposure of AE mode
To change shutter speed to program mode
To change shutter speed to 1/60 (PAL: 1/50)
To change shutter speed to 1/12 (0PAL: 1/100)
To assign shutter speed
4 ﬁgures Hexadecimal value within the request of focus limit
The focus range changes according to the zoom position. The value indicates Max/Min 4 ﬁgures in
The zoom value is to set individually inherent value within 0000h FFFFh
System control Command Table
Remote Control ON
Remote Control OFF
Operation Status Request
Extended Operation Status Request
Product Name Request
ROM Version Request
Preset Status Request
Extended Preset Status Request
Remote Controller Through Setting
LED Normal Display
LED Forced Control
Host Control Mode
Local Control Mode
Display Character Data Assignment
Display Character Data Request
Display Date Setting
Display Date Request
Display Time Setting
Display Time Request
Turning On Time Request
Command Termination Notiﬁcation
Global Notiﬁcation Setting
Pedestal Model Request
Camera Model Request
To available remote controller
To inhibited remote controller
To return information of operate status
To return extended information of operate status
To return product name
To return ROM version of VC-C4
To memory preset position
To move preset position
To request preset status
To request extended preset status
To set ON/OFF of remote controller through
To set normal display of LED
To set forced ON/OFF of LED
To release cascade connection OFF
To connect cascade connection ON
To control by host computer
To control by remote controller
To set screen display of date, time, characters
To assign character data of display
To request character data of display
To set display date (yy/mm/dd)
To request display date (yy/mm/dd)
To set display time (hh/mm/ss)
To request display time (hh/mm/ss)
To request total accumulated turn on time
To initialize in status of factory setting
To set termination notiﬁcation on/oﬀ
To set global notiﬁcation on/oﬀ
To return pedestal model (normal/inverse)
To return camera model (NTSC/PAL)
XX, Y, DD indicate X address, Y address, ,Character Data of Display in Hexadecimal
YY, MM, DD indicate Year, Month, Day in Hexadecimal
HH, MM, SS indicate Hour, Minute, Second in Hexadecimal
* Your assessment is very important for improving the work of artificial intelligence, which forms the content of this project