Android Tutorial Android based Closed Circuit TV (CCTV) example

Similar threads

B4A Tutorial MJPEG / CCTV Server
B4A Question CCTV between two mobiles
B4A Question Camera Preview Memory Leak?
B4A Tutorial Intent Based Camera
Games [XUI2D] Example Pack

Giuliano Cucchiarini

Member
Licensed User
This example is made of two components:

Client - Basic4android program that takes the camera preview frames and sends them to the server.

Server - C# program that accepts incoming connections and shows the camera frames.

The code of both components is pretty simple and is a good example of creating network based solutions. Note that both the client and server components should overcome network problems and continue to work when the network is again available.

How to run this example
1. Find the desktop ip address (you can run ipconfig from the command line).
2. Set this address in the device program - ServerIp variable.

Most complicated step:
3. By default Windows firewall blocks incoming connection. You need to open the firewall settings and add an exception for port 17178 (TCP).
Windows 7:



Run the desktop program and press Start.
Run the device program and check the logs in the IDE.

The source code of both projects is attached as well as the compiled desktop executable.

This example requires Android 2.2+ as the API that converts the preview image to JPEG is not available on older devices. The reflection library is also required.

Feel free to ask any question about this implementation.

The client code was updated to use CameraEx class. Note that it requires Camera library v2.0+.
This example is made of two components:

Client - Basic4android program that takes the camera preview frames and sends them to the server.

Server - C# program that accepts incoming connections and shows the camera frames.

The code of both components is pretty simple and is a good example of creating network based solutions. Note that both the client and server components should overcome network problems and continue to work when the network is again available.

How to run this example
1. Find the desktop ip address (you can run ipconfig from the command line).
2. Set this address in the device program - ServerIp variable.

Most complicated step:
3. By default Windows firewall blocks incoming connection. You need to open the firewall settings and add an exception for port 17178 (TCP).
Windows 7:



Run the desktop program and press Start.
Run the device program and check the logs in the IDE.

The source code of both projects is attached as well as the compiled desktop executable.

This example requires Android 2.2+ as the API that converts the preview image to JPEG is not available on older devices. The reflection library is also required.

Feel free to ask any question about this implementation.

The client code was updated to use CameraEx class. Note that it requires Camera library v2.0+.
Is it possible to add also AUDIO?
 

Beja

Expert
Licensed User
Server - C# program that accepts incoming connections and shows the camera frames.
Hi Erel,
I understand b4j was not released at that time.. but I am not familiar with C# and have little time to study it (if interested at all)
Is there any plans to port the server to B4J?

Thanks in advance
 

jonydoboi

Member
Licensed User
I get this error message.
Do have B4A 2.30
I deleted the designerscript and the program compiled but still had an error.
An error has occurred in sub: cameraexclass_takepicture (java line: 451)
NullPointerException.
It is a front facing camera.
 

Attachments

Last edited:

Erel

Administrator
Staff member
Licensed User
I'm not sure that this project will work at all with v2.30. Try to use Java 6 instead of Java 7. V2.30 doesn't support Java 7.
 

sasidhar

Active Member
Licensed User
This example is made of two components:

Client - Basic4android program that takes the camera preview frames and sends them to the server.

Server - C# program that accepts incoming connections and shows the camera frames.

The code of both components is pretty simple and is a good example of creating network based solutions. Note that both the client and server components should overcome network problems and continue to work when the network is again available.

How to run this example
1. Find the desktop ip address (you can run ipconfig from the command line).
2. Set this address in the device program - ServerIp variable.

Most complicated step:
3. By default Windows firewall blocks incoming connection. You need to open the firewall settings and add an exception for port 17178 (TCP).
Windows 7:



Run the desktop program and press Start.
Run the device program and check the logs in the IDE.

The source code of both projects is attached as well as the compiled desktop executable.

This example requires Android 2.2+ as the API that converts the preview image to JPEG is not available on older devices. The reflection library is also required.

Feel free to ask any question about this implementation.

The client code was updated to use CameraEx class. Note that it requires Camera library v2.0+.

Does this Example works if the IP is Static IP and Server Application at this Static IP.
 

sasidhar

Active Member
Licensed User
I tried with Local WIFI 192.168.1.4 is the IP and port as mentioned 17178.

Port Added in windows Firewall settings

When I Run Application from Mobile I get Error Connecting..

Log"(ErrnoException) libcore.io.ErrnoException: isConnected failed: ECONNREFUSED (Connection refused)"

I have disconnected B4A Bridge also, still same issue.

Please let me know what could be the issue..

Thanks
Sasidhar
 

Erel

Administrator
Staff member
Licensed User
You will be able to connect to the device over the internet and see the camera frames.
 
Top