Animal Cage Camera (A3034)

© 2018-2025 Kevan Hashemi, Open Source Instruments Inc.
© 2018 Michael Collins, Open Source Instruments Inc.

Contents

Description
Versions
Set-Up
Lenses
Exposure Compensation
Color Saturation
Color Balance
Design
Modifications
Commands
Development

Description

[18-MAR-25] The Animal Cage Camera (ACC version A3034) operates with the Videoarchiver Tool to provide high-definition, compressed video that is synchronous with biometric signals recorded by our subcutaneous transmitters (SCTs). The ACC is a black-anodized aluminum cuboid that sits securely on a flat surface for horizontal viewing, mounts in a mobile phone stand for elevated viewing, and fits behind the cages of a an individually ventilated cage (IVC) rack where we can zip-tie it to the ventilation pipes.


Figure: Two Animal Cage Cameras (A3034C2-A). Left: white LEDs on dim. Right: infrared LEDs on full power, seen through the infrared blocking filter of our mobile phone camera.

The ACC provides independent, variable-intensity, white and infrared light-emitting diodes (LEDs) to illuminate their own field of view. With the help of a day-night program running with the Videoarchiver, we can alternate between white and infrared light do simulate night and day. Its lens has no infrared blocking filter. The lens provides gray-scale images in infrared light, and balanced, crisp, full-color images in the light of its white LEDs. With the help of the Videoarchiver's scheduling component, we can alternate white and infrared illumination during day and night hours, and so obtain full-color images during the day, and gray-scale images at night.

The ACC offers three significant advantages over commercially-available webcams. Its video recordings are synchronous to ±100 ms with respect to a central data acquisition computer's clock. We can place the camera right up against an animal cage wall and view the entire cage without seeing its own infrared or white LEDs reflected in the wall. We can use the ACC recordings directly with the Neuroplayer to navigate through telemetry recordings.


Figure: The A3034C Held By a Mobile Phone Mount. The mount is made by Evanto. Note the hole above the lens, which gives access to the firmware reset switch.

Power and communication are provided to the ACC by a single Power-over-Ethernet (PoE) cable. A single PoE switch with twelve or more ports allows us to connect ten ACCs, a LWDAQ Driver, and a data acquisition computer to the same local network. With such a network, we can record biometric signals from dozens of animals, along with synchronous video of those same animals from ten different points of view. The A3034C's wide-angle DSL227 lens and IMX219 full-color image sensor together provide a 148-degree diagonal field of view. When delivered by OSI, the center of the A3034C's depth of field is at range 40 cm, which provides sharp images of objects from ranges 20 cm to infinity. We say the focal range of the camera is 40 cm, and the depth of field is 20 cm to infinity. If we want to view objects 10 cm away, we adjust the lens-fastening screws so they allow the lens to rotate smoothly but with resistance, so the lens will remain where it is when we let go of it. WE rotate the lens counter-clockwise to reduce the focal range. We do not tighten the screws after we adjust the focal range, because tightening the screws moves the lens and changes the focal range. The A3034C offers two video output formats. The A3034B-HR format is 820 pixels wide and 616 pixels high (820 × 616) at twenty frames per second (20 fps) with standard-quality output. The A3034B-LR format is 410 × 308 at 30 fps with high-quality output. The video files produced by both formats take up roughly 5 GByte/day when viewing animals in a cage with infra-red illumination at night. The low-resolution format provides sharper images of fast-moving animals, while the high-resolution format provides sharper images of small, slow-moving animals.


Figure: Night Images of the OSI Office, Different Color Saturation and Exposure Compensation. Left: Sat 0.0, Exp 0.0. Center: Sat 0.5, Exp 0.5. Right: Sat 1.0, Exp 1.0. We set Sat and Exp in the Videoarchiver.

The ACC is intended for operation in clusters of up to ten cameras, all controlled by one Videoarchiver Tool. The Videoarchiver provides live display of camera video on the computer screen for use when you set up your camera. The delay between movement in the camera field of view and its appearance in the live display should be less than fifty milliseconds. To record video to disk, we stop the live display, and instead initiate segmentation and compression of video on the camera itself, which the Videoarchiver downloads and concatenates into time-stamped video files that are synchronous with the local data acquisition computer clock. While recording to disk, we can view the compressed video as it arrives at the data acquisition computer, but this view will be delayed by several seconds. This delay does not represent a lack of synchronization with the local clock.

The video produced by the A3034 is compressed with the H264 algorithm using crf=23 (constant rate factor set to twenty-three), which provides well-defined images of moving animals. A ten-minute, 820 × 616, 20 fps video of moving animals will occupy roughly 30 MBytes on disk. The compressed video contains key frames at the start of every whole second marked by the data acquisition computer's clock. These key frames allow the Neuroplayer to jump quickly and accurately to any whole-second boundary within the video recording, and at the same time display the simultaneous biometric signals with synchronization accuracy ±50 ms.


Figure: Example Animal Cage Camera Recording. A one-minute recording made with an A3034X raised 15 cm above a table top. The lens is a DSL215 providing a 180-degree diagonal field of view. The 820×410, 20 fps video is compressed with the ffmpeg: implementation of the H264 codec, using options "-preset veryfast" and "-crf 23". The file is 7.4 MBytes long.

The ACC is designed to be quiet and reliable. Its power converters are long-live, encapsulated devices run at frequencies well above the ultra-sonic frequencies mice can hear. The ACC contains no fan. It dissipates the heat generated by video compression by means of conduction, radiation, and un-forced convection alone. During video recording, its case will be 15°C warmer than ambient. The PoE switch that supplies power and communication for the cameras should be quiet also. We recommend a switch such as the GS116PP, which has no fan and provides more than 12 W electrical power for each of ten cameras.


Video: Latency of the A3034C2. We see movement being propagated through repeated images so as to show the camera latency. By playing the video in slow motion, we measure the latency to be four frames, which is 100 ms.

Each ACC requires only one cable for power and communication, but we must use the right kind of cables. For gigabit PoE connections, we must use Cat-5E or higher network cables. The A3034B (cameras S0205-S0217) requires that we use unshielded cables from the switch to the Faraday enclosure because of a weakness in its design. The A3034C and later versions work fine with either shielded or unshielded cables from the switch to the Faraday enclosure. Our subcutaneous transmitters systems almost always operate within some kind of Faraday enclosure, such as the FE3AS). These enclosures are designed to be electrically quiet, both at the low frequencies of biometric signals, and the much higher frequencies of radio-frequency interference. When we install a camera inside such an enclosure, we rely upon the aluminum case of the camera to keep its own electrical noise contained, but we must in addition use a shielded network cable between the camera and the Faraday enclosure wall. Thus, we always use a short, shielded network cable to connect the feedthrough to the camera inside the enclosure. If we do not use a shielded cable inside the enclosure, we introduce mains hum and radio-frequency interference into the enclosure volume.

Versions

[18-MAR-25] We can equip the A3034 with a variety of lenses, each of which gives the camera a different field of view and color balance. As time goes by, we adapt the A3034 to accommodate changes in the third-party software and hardware that we use to construct the cameras.

Version Features Image Sensor Lens FOV Video Markings
A3034B1-A Raspberry Pi 3B+, raspivid interface.
Requires unshielded cable to Faraday enclosure
IMX219 DSL227 148° 820 × 616, 20 fps,
H264, crf=23
None
A3034C1-A Raspberry Pi 3B+, raspivid interface. IMX219 DSL227 148° 820 × 616, 20 fps,
H264, crf=23
None
A3034C2-A Raspberry Pi 3B+, libcamera interface. IMX219 DSL227 148° 820 × 616, 20 fps,
H264, crf=27
Orange Dot
A3034C2-B Raspberry Pi 3B+, libcamera interface. IMX219 DSL215 180° 820 × 616, 20 fps,
H264, crf=27
Orange Dot
Table: Versions of the A3034. We specify diagonal field of view (FOV) in degrees. Markings on the serial number label help identify the camera version.

The original A3034 cameras used the raspivid library interface on the Raspberry Pi 3B+. This interface was later retired and rendered obsolete by Raspberry Pi. We could no longer buy camera modules that supported the raspivid library. We were forced to move to the libcamera library and purchase the newer camera modules. But it turned out that the color balance we obtain with the new library is significantly better than with the old.

Set-Up

Warning: Do not over-tighten lens screws. Over-tightening spoils the camera focus.

Warning: Do not plug the camera into a LWDAQ Driver. Doing so will damage the camera.

[07-DEC-23] In order to communicate with your ACC when you first receive it, you must configure your computer's wired Ethernet interface to communicate on subnet 10.0.0.x. You assign your computer an IP address like 10.0.0.2, and you give it "subnet mask" 255.255.255.0. On MacOS, create a new location with the Locations Manager, which is accessible through the Networks icon in System Settings. Select your wired Ethernet connection and configure it using the graphical user interface of the Locations Manager. We have specific instructions for Windows 7 and Windows 10. On Linux, you edit file /etc/dhcpcd.conf to configure your wired ethernet interface, which may be called eth0, or may be called something long and cryptic if you have "predictable interface names" on your version of Linux.

The diagram below shows how four ACCs, a data acquisition computer, and a LWDAQ Driver (A2071E) connect to the same local network provided by a single PoE switch. Two cameras are set up outside a Faraday enclosure, and two more are set up inside the the Faraday enclosure. An Octal Data Receiver A3027E is connected to the LWDAQ Driver and to two Loop Antennas (A3015C) within the same Faraday enclosure. These antennas receive signals from subcutaneous transmitters (SCTs) implanted in the same animals the cameras are arranged to view.


Figure: Animal Cage Camera and Octal Data Receiver Connections. Cables that must be shielded network cables are thick, solid lines. Thick, hollow lines must be unshielded network cables when used with the A3034B camera (cameras S0205-S0217), but can be shielded or unshielded for the A3034C and later. Coaxial cables for radio frequency signals are thin, solid lines. Two BNC feedthroughs provide connection for coaxial cables running to antennas inside a Faraday enclosure. Two shielded RJ-45 feedthroughs provide connection for network cables running to cameras inside the same enclosure.

We must use shielded network cables inside the enclosure. From the enclosure wall to the PoE switch, we can use shielded or unshielded cables if our cameras are version A3034C or later, but for the A3034B (cameras S0205-S0217) we must use unshielded cables from the enclosure to the switch.


Figure: Shielded (blue) and Unshielded (yellow) Cat-5E Network Cables. Shielded cables are terminated with connectors that have a shiny metal housing.

The ACC and SCT recording system requires three connections to AC wall power. The data acquisition computer, PoE switch, and LWDAQ Driver each connect to AC power with their own power adaptors. Power for the cameras is delivered by the PoE switch through network cables. When we first connect power, the camera will boot up. Its white lights turn on to full power, then dim to half-power. After about thirty seconds, the white lights flash three times, indicating that the camera is ready to run. On the front face of the A3034 there is a hole, and behind this hole is its configuration switch. Press this switch with a pointed object while the white lights are flashing three times, and you will reset the camera's static IP address to the value 10.0.0.34. The white lights will flash rapidly five more times to confirm that the new IP address has been implemented.

We do not ship the ACC with address 10.0.0.34. Instead, we ship each with an IP address 10.0.0.X, where X we obtain from the last three digits of the camera's serial number. The serial number label is just above the camera's RJ-45 socket. Camera S0205 ships with IP address 10.0.0.205, and camera V0054 ships with IP address 10.0.0.54. The ACC always operates with a fixed, or static, IP address, and will never permit its IP address to be assigned by the dynamic host communication protocol (DHCP) that operates on all institutional networks. The ACC is designed to operate on an isolated, gigabit, PoE network, in which there is no possibility of any external client connecting to the camera, hijacking its video, or infecting it with a computer virus. But the Videoarchiver allows us to change an ACC's static IP address to any other value we like, at the press of a button. We must, however, know the existing IP address of the camera in order to communicate with it, so if we have lost all record of an ACC's IP address, we must resort to resetting the camera's IP address to 10.0.0.34 with the configuration switch.


Figure: The Set IP Panel. We can assign a new IP address to a camera, and a router for our local subnet.

We could, for example, configure our camera to use a static IP address on our own local laboratory network, perhaps its subnet is 129.33.33, and we assign our camera address 129.33.33.89. If we want to make it impossible for the camera to communicate with devices outside the 129.33.33 subnet, we leave the camera's "router address" set to "0.0.0.0". But if we want the camera to be available over the wider internet, we can set the router to "129.33.33.1", or whatever the address of our subnet's router might be.


Figure: Videoarchiver Version 28 on MacOS, Recording from Thirteen Cameras. Each camera is named after its serial number, and each IP address is derived from that same serial number.

To set up your cameras, open the Videoarchiver in the Tool Menu of our LWDAQ program. Before you use the Videoarchiver for the first time, you must download and install the Videoarchiver Libraries. Having done this, enter the IP address of one of your cameras in one of the IP entry boxes, and try turning on and off the white LEDs. If you see them turning on and off, the camera is connected and ready. You can also use the Query button (if available in your Videoarchiver) to download log files from the camera, which also serves to show that the camera is ready to stream or compress video. The Live button gives you a live picture, and you can use this to check the focus of the camera, and choose the illumination intensities necessary to provide the best color balance and contrast during day and night recording. The exposure compensation setting allows you to get a better view of dim objects or bright objects. The rotation settings allow you to pre-rotate the incoming video so it will be recorded the right way up. The version setting allows you to pick the resolution and frame rate of the video you record.

Lenses

[07-MAY-19] Our preferred supplier of lenses is Sunex. The table below summarises the properties of a few lenses when used with the A3034's IMX219 image sensor. This sensor is 3.7 mm wide and 2.8 mm high. The horizontal field of view of a lens when combined with the IMC219 image sensor is the angular field of view of the camera along the 3.7-mm width of the sensor. The diagonal field of view is the field of view along the 4.8-mm diagonal of the sensor. The field of view provided by a lens is always a circle. If the circle just fills the width of the sensor, our image will have dark corners, and the horizontal and diagonal fields of view will be the same. If the circle just fills the entire sensor, the diagonal field of view will be greater than the horizontal. We prefer to equip the A3034 with a lens that fills the entire sensor with its image.

Lens Effective
Focal
Length (mm)
Horizontal
Field of
View (deg)
Diagonal
Field of
View (deg)
Comments
DSL2122.0102140Full sensor image, Cost $50
DSL2151.6135180Full sensor image, sharp focus, cost $100
DSL2161.3187187Circular image, sharp focus, cost $100
DSL2192.0116160Full sensor image, sharp focus, cost $100
DSL2242.298134Full sensor image, cost $50
DSL2272.0108148Full sensor image, sharp focus, cost $100
DSL8538.02432Full sensor image, sharp focus, $50
Table: Summary of Lens Performance in the A3034 Camera.By default, we equip the ACC with lenses that have no infrared-blocking filter. But if you are going to use the ACC to record video in sunlight or incandescent light, consider asking us to provide a lens with infrared blocking to correct the image color balance.

The lenses that give sharp focus across the entire field of view cost twice as much as those that provide only one of these two qualities. The DSL212, for example, provides a wide field of view, but at $50, it does not provide resolution to match our image sensor.


Figure: DSL212 Images in White (Left) and Infrared (Right) Light.

The DSL219, on the other hand, provides sharp images and great depth of field over its 116° field of view, but at a cost of $100. We include a lens like the DSL219 with each A3034 camera we ship. If you have space to look down upon a rectangular animal cage from a height of 30 cm, this is the lens we recommend.


Figure: DSL219 Images in White (Left) and Infrared (Right) Light.

The DSL227 provides a wide field of view, splendid, sharp focus, and great depth of field. It is also a $100 lens. If you want to place your lens close to a rectangular animal cage, this is the lens we recommend.


Figure: DSL227 Images in White (Left) and Infrared (Right) Light.

We suggest you consider the depth of field and angular field of view your application demands, and then we will choose with you a lens that provides the best use of the image sensor to provide bright, sharp images of your animals.


Figure: Narrow Field of View (10°) with Infra-Red Blocking Filter, Focused at Infinity.

The above image shows near objects out of focus and distant objects in focus. The focal range of the camera is infinity, meaning we have made the focus sharp for distant objects. By default, we focus the A3034 at range 40 cm in the factory before we ship. You can adjust the focus by turning the lens and watching a live image.

Exposure Compensation

[09-JUN-22] The A3034 camera adjusts its exposure time automatically to suit the illumination in the image. But it can favor the dimmer parts of the image or the brighter parts of the image, and we control which parts it favors by setting its exposure compensation.


Figure: Exposure Compensation Adjustment in A3034C1 Camera. Exposure compensation values 0.0 (Left), 0.5 (Center), and 1.0 (Right). All with color saturation 0.5. Note the the color balance in this image is poor: we have sunlight entering the windows of our office, bringing infrared light into the field of view. The shirt is in fact blue, not purple.

The Videoarchiver allows us to set the exposure compensation value to any integer between 0.0 and 1.0 with a menu button. Once recording begins, we cannot adjust the compensation without stopping and starting again.


Figure: Exposure Compensation Adjustment in A3034C2 Camera. Exposure compensation values 0.0 (Left), 0.5 (Center), and 1.0 (Right). All with color saturation 0.5 in white LED lighting.

In the photos above, colors are rendered better because the lighting is better, but also because the A3034C2 provides better color balance, exposure compensation, and color saturation than the A3034C1 camera.

Color Saturation

[21-JAN-23] In the Videoarchiver, we can adjust the brightness of colors with the color saturation value. The Videoarchiver allows us to set the color saturation to any integer between 0.0 and +1.0 with a menu button. Once recording begins, we cannot adjust the saturation without stopping and starting again. The photographs below shows how the saturation value brightens the colors in A3034C1 video.


Figure: Color Saturation Adjustment with A3034C1 Camera. Color saturation values 0.0 (Left), 0.5 (Center), and 1.0 (Right). Click for larger images. All with exposure compensation Exp = 0.5 in white fluorescent lighting.

The A3034C2 camera uses the libcamera video routines instead of the older raspivid routines. The result is superior handling of color brightness, as we can see in the example image below, taken from an A3034C2.



Figure: Color Saturation Values in A3034C2 Camera. Color saturation values 0.0 (top-left), 0.4. 0.5. 0.7, and 1.0 (bottom-right). All taken with exposure compensation Exp = 0.5 in white LED lighting.

We recommend a saturation value of 0.5 for looking at animals in dimly-lit cages, but we leave it to the experimenter to find the value that gives the best color contrast for animal viewing.

Color Balance

[15-MAR-24] A standard ACC is equipped with a lens that focus images of both visible and infrared light. The camera obtains gray-scale images by the light of its own infrared lights at night, and full-color images by its own white lights during the day. Sunlight contains infrared light as well as white light, so the images we obtain with the ACC in sunlight appear purple, as we can see in the image below, where the view out the windows is purple.


Figure: Sunlight Compared to White Light. Sunlight contains infrared light that gives our camera images a purple tint.

In white LED light, such as the white light provided by the ACC's white lamps, the IMX219 image sensor provides bright, accurate color images like the one shown on the left below.


Figure: Images of Brightly-Colored Object in White LED Light (Left), Infrared LED Light (Center), and White Plus Infrared Light (Right). Click for higher-definition image.

In infrared light, the camera provides a monochrome image. Its red, green, and blue pixels are all equally sensitive to infrared light, so no colors emerge in infrared illumination. When we mix the two, we get shades of red and blue, but green objects appear gray. Sunlight and incandescent lights provide a mixture of visible and infrared light. The ACC with its standard lenses provides poor color balance when viewing objects in natural light or in rooms lit with light bulbs. We can, however, equip the ACC with an infra-red blocking lens if your application uses natural light exclusively.


Figure: Relative Response of Red, Green, and Blue Pixels versus Wavelength for IMX334C Image Sensors.

We do not have the relative response of the IMX219C image sensor, but we expect it to be much the same as that of the IMX334C, shown above. The A3034A's infrared emitter is the APT2012F3C, with peak emission wavelength 940 nm. Our white LEDs are the L130-2780, which appears to the human eye to be the same color as an object at 2700-Kelvin. The actual emission spectrum of the LED is not a black-body emission spectrum, as shown below.


Figure: Spectra of Various White LEDs.

The white LED is actually a blue LED covered with yellow phosphor. The result is a combination of blue and yellow light that appears to our eyes to be the white. The color of objects in this light, may not be the same as the color they would appear in incandescent or fluorescent light. We adjust the color balance of our cameras to provide the best colors in the light of the camera's own white LEDs. If you see variation in color balance across your camare field of view, try updating to the latest Videoarchiver and then updating your camera color balance with the update button. The update will install the latest color balance tables.

Design

[23-OCT-19] The A3034X and A3034A were prototype versions of the Animal Cage Camera. We replace them with the all-purpose A3034C, which comes in a rugged, heat-dissipating, black-anodized enclosure, and may be mounted on a stand, zip-tied to a structure, or allowed to sit with the stability of its own weight upon a flat sufrace. We can adjust the focus of the lens by rotating it in its threaded holder. Two screws allow us to secure the lens during adjustment so that it does not move when we let go of it, or later when we move the camera. We can reset the camera's IP address by pressing the configuration button while the camera boots up. We can vary the intensity of the white and infrared LEDs. The A3034B was an intermediate version in which we did not implement full isolation between the chassis and the Power-over-Ethernet negative terminal, resulting in a device that could create ground loops when used with shielded cables.

S3034C_1: Animal Cage Camera Schematic for Version C.
S3034C.ods: Bill of Materials for Animal Cage Camera Version C.
A303401D.zip: Gerber files of PCB for A3034C.
A303401D Top: Drawing of A303401D printed circuit board top-side.
A303401D Bottom: Drawing of A303401D printed circuit board bottom-side.
S3034B_1: Animal Cage Camera Schematic for Versions B.
S3034B BOM: Bill of Materials for Animal Cage Camera Versions B.
A303401C.zip: Gerber files of PCB for A3034B.
A303401C Top: Drawing of A303401C printed circuit board top-side.
A303401C Bottom: Drawing of A303401C printed circuit board bottom-side.
A3034B Enclosure: Drawings of the enclosure back, front, and sides.
Raspberry Pi: Home page for embedded Linux modules.
Camera V2: Manual for Camera Module Version Two with IMX219 image sensor.
UC-350: UCTronics UC-350 RevD Arducam, provides 20.00 frames per second.
ffmpeg: The video encoder we use generate video files.
Code: Animal Cage Camera firmware and software.
S3034A_1: Animal Cage Camera Schematic for Versions A and X.
A303401A.jpg: View of A303401A printed circuit board.
A303401A.zip: Gerber files of PCB for A3034X.
A303401B.zip: Gerber files of PCB for A3034A.
A303401B Top: Drawing of A303401B printed circuit board top-side.
A303401B Bottom: Drawing of A303401B printed circuit board bottom-side.
CC3-4812SR-E: Converter for PoE to lamp power, first model.
BTB48-12W12S: Converter for PoE to lamp power, second model.
CC10-4805SR-E: Converter for PoE to computer power.

The S3034C_1 schematic shows the A3034AUX-C auxiliary circuit we add to the Raspberry Pi3B+ to provide Power-over-Ethernet (PoE) conversion, white LED lighting, infrared LED lighting, and a configuration switch. The earlier S3034B_1 shows the earlier A3034AUX-B circuit, which did not provide isolation between the PoE and the A3034 power supplies.


Figure: The Auxiliary Circuit (A3034AUX-B) Top Side. Showing LED arrays and configuration switch. The A3034AUX-B is made with the A303401C PCB. The design was flawed in that it did not provide full isolation between the internal power supplies and the PoE power supply. Replaced subsequently by the A3034AUX-C made with the A303401D PCB.

A four-way ribbon cable brings the four possible PoE voltages from the RJ-45 socket on the Pi3B+ and delivers them to P1, where a bridge rectifier generates the POE and 0V potentials. Transistors Q1 and Q7, along with zener diode Z1 and some resistors provide both PoE detection and connection. We describe the operation of this PoE switch below. Converter L1 CC10-4805SR converts 48-V PoE power to 5-V at 2 A for the Pi. Converter L2 CC3-4812DR converts PoE to 24 V for the LEDs. The white and infrared LEDs are controlled by separate four-bit DACs. The Videoarchiver presents buttons for power levels 0 to 4, which it maps onto the DAC values 0 to 15 to give a useful progression of output power. Switch S1 is examined by the Pi when it boots up, and if pressed will cause the Pi's Ethernet configuration file to be over-written by the factory default configuration, which is a static IP address 10.0.0.34.


Figure: The Auxiliary Circuit (A3034AUX-B) Bottom Side. Showing DC-DC converters and connections to Pi3B+.

The A3034 lens and image sensor provide superb video of moving animals in dim and bright light, both near and far from the camera. The Pi3B+ provides a graphical processing unit (GPU), and we enlist this processor to compress the twenty individual 820×416 frames per second produced by our image sensor into high-resolution images. Despite the compression of the individual frames, this video still occupies 2 MByte/s on disk. When compressed by the inter-frame H264 algorithm (with quality setting crf=23), the video occupies only 40 kByte/s and retains all the clarity of the original. If we are to connect ten such cameras to a single data acquisition computer, we must either compress the video in the camera itself, or compress the video on the computer. Even a gigabit Ethernet will be unable to transfer 200 MByte/s continuously. And even a powerful desktop computer will be burdened by the job of compressing ten video streams in real time. Thus the A3034 must perform its own compression. During recording, the Videoarchiver synchronizes the clock on each camera every few minutes, and each camera records its video into one-second segments that begin and end on the one-second boundaries of its clock. The Pi3B+ has four microprocessor cores each running at 1.4 GHz. We use three of these to compress the video segments in parallel. The data acquisition computer has only to download the compressed segments and concatenate them into files with timestamped names. This it can do easily for ten cameras over a gigabit Ethernet.


Figure: Color Comparison. Left: A3034C1. Center: A3034C2 with Videoarchiver 33. Right: A3034C2 with Videoarchiver 34. Saturation and Exposdure both 0.5.

The A3034C1 and A3034C2 differ in their internal video-handling software. The C2 provides better color balance, especially after updating with Videoarchi ver 34+. Two determine whether your camera is a C1 or C2, use the Q button in the Videoarchiver to query the camera. If the camera's operating system is listed as "Bullseye", it's a C2. Otherwise it's a C1.

Each A3034 provides a file "videoarchiver.config" that contains text lines identifying its operating system and hardware configuration. Right now we have two versions of this file. The first, which is present on A3034B and A3034C1 cameras, is as follows.

sensor IMX219
platform Pi3+
assembly A3034B

The second, which is present on A3034C2 and A3034D2 cameras, is as follows.

sensor IMX219
platform Pi3+
assembly A3034B
os Bullseye

The purpose of this file is to let the Videoarchiver know what image dimension, frame rate, and video libraries are available on the camera. In both these examples, the IMX219 is the image sensor, which dictates the available image dimensions. The additional "os Bullseye" line we added to the C2/D2 cameras in order to inform the Videoarchiver that it should use libcamera routines rather than the older raspivid routines.

Modifications

[11-MAY-18] The A303401A circuit board requires that we displace L1 and add wire links to accommodate an inverted footprint. The result is our A3034X with half and full-power visible illumination and full-power infrared illumination.

[09-OCT-19] The A303402C circuit board requires the following modifications. (1) A wire link between L2-2 on the component itself and the pad for L2-2 on the PCB footprint. (2) Cover the low-voltage end of R21 with two layers of kapton tape so it does not make electrical contact with the camera lens holder.

[19-OCT-19] We made 15 A3034B cameras using the A303402C circuit board. We will re-work this board for future ACCs, with these corrections.

  1. Correct footprint of L2.
  2. Move R21 out of the way of the lens holder.
  3. Reinforce the footprint of P1 so as to make it harder to pull off.
  4. Isolate the rectified PoE negative voltage from the camera 0V potential, so as to avoid PoE current flowing through a cable shield rather than the cable's internal conductors. Both L1 and L2 are isolated DC-DC converters, so we will isolate the PoE input 0V from the converter output 0V.

[14-JAN-20] The A303402D implements the above changes. We distinguish the newer ACC by giving it assembly number A3034C.

Commands

A list of shell commands we have used to get things done in our tests, and in preparing Raspberry Pi disk images.

# The fdisk command (fixed disk) is available on all Linux and Unix platforms.
# Here use it to obtain a list of disks and partitions.
sudo fdisk -l

# Here we call fdisk on a disk so we can create partitions, then format with
# ext4 file system.
sudo fdisk /dev/sda1
sudo mkfs.ext4 /dev/sda1

# The mount command (mount a disk) attaches a partition to a directory. The
# directory must exist before-hand. If we don't specify a directory, mount looks
# in the /etc/fstab text file (file system table) for an entry that specifies
# where this device should be mounted.
sudo mount /dev/sda1 ~/Desktop/USB

# The unmount command (unmount a disk) detaches a partition from a directory.
sudo umount /dev/sda1

# The dd command (data duplicate) command copies files, channels, partitions, or
# entire disks with their boot partitions and tables. Here we copy the entire
# contents of the device /dev/sda to a file with extension img to mean "disk
# image". Note that we are not copying a partition, nor do we need to know
# anything about the structure or format of the device. We simply go to the
# first byte and copy every byte on the device until the operating system gets
# and end-of-file message from the device.
sudo dd if=/dev/sda of=A3034B_24MAR20.img

# We can use dd to copy a disk image file onto a device, overwriting as much of
# the device as required to accommodate the image. We don't specify a partition
# in the following command, only a device that will be written to, starting with
# the first byte of the device. We are also specifying that the dd command
# should indicate its progress as it goes along, and that it should copy in
# 1-MByte chunks, to speed things up.
sudo dd if=P3034B_24MAR20.img of=/dev/sda status=progress bs=1MB

# The following line in the fstab file creates a 64-MByte RAM disk mounted on
# the tmp directory.
tmpfs /home/pi/Videoarchiver/tmp tmpfs nodev,nosuid,noexec,nodiratime,size=64M 0 0

# We write zeros to all unused space on a partition with this use of dd, which
# reads zeros from the zero channel. We then delete the temp.txt file and we
# have all unused space as zeros.
dd if=/dev/zero of=temp.txt
rm temp.txt

# When we copy the drive to an image, we can now use the sparse file format to
# store the zeros simply as a number of zeros, rather than writing them to disk.
# A 16 GB image with 13 GB of zeros takes up only 3 GB as a sparse file.
sudo dd of=P3034B_24MAR20.img if=/dev/sda status=progress bs=1MB conv=sparse

# We can compress the sparse file and preserve its sparse format with the tar
# utility. Here we run the original image through tar with the -S option to
# preserve the sparse file, then with z we call gzip to compress further.
tar -cSzf P3034B_24MAR20.tar.gz P3034B_24MAR20.img

# We decompress the archive like this.
tar -xSf P3034B_24MAR20.tar.gz P3034B_24MAR20.img 

# If we want to reduce the size of a partition, we must first make sure, as
# above, that we are going to lose only zeros. We use the gparted utility (gnu
# partition editor) to shrink partitions.
sudo apt-get install gparted

# List the block devices. Shows you the devices connected to the hardware,
# mounted or un-mounted. The list is presented as a tree, and provides the mout
# point directories when they exist.
lsblk

# The df command (disk filesystem) writes a list of all mounted devices.
df

# Run a video through ffmpeg to produce H264 compressed output in mp4 container.
# The ffmpeg input processor detects the input file type, first by checking the
# file extension, and then by checking the headers in the file, whichever works.
ffmpeg -i inputfile -c:v libx264 -crf 23 -preset veryfast output.mp4

# Shrink 820x616 video with ffmpeg down to half-size.
ffmpeg -i V1525694641.mp4 -c:v libx264 -preset veryfast -crf 23 -vf scale=410:308 shrunk.mp4

# Crop video to 720x900 with top-left corner of cropped region at x=0, y=100.
ffmpeg -i V1.mp4 -ss 00:00:00 -t 00:01:17 -filter:v "crop=720:900:0:100" V1_cut.mp4

# Read in a video and force key frames every half-second.
ffmpeg -i input.mp4 -force_key_frames "expr:eq(t,n_forced*0.5)" output.mp4

# Make montages of key frames so we can see them and count them.
ffmpeg -skip_frame nokey -i input.mp4 -vf 'scale=128:72,tile=8x8' -an -vsync 0 keyframes%03d.png

# Correct the frame rate of a video when the camera clock is off. Here we correct a
# ten-minute video containing 12004 frames in which the frame rate and time stamps
# give the video a length of 600.25 s.
ffmpeg -i infile.mp4 -filter:v "setpts=0.999667*PTS" outfile.mp4

# Read a video and print out information. The number of frames, for example, will be
# written after "frame=".
ffmpeg -i infile.mp4 -c copy -f null -

# Report on the network interface configuration, then disable the wlan0 and enable it.
ifconfig
sudo ifconfig wlan0 down
sudo ifconfig wlan0 up

Development

[18-MAR-25] For an account of the development of the A3034, and its continuing production, see its Development and Production page.