News:

;) This forum is the property of Proton software developers

Main Menu

Connect Camera to pic

Started by Amateurtje, Jul 23, 2021, 05:40 PM

Previous topic - Next topic

Amateurtje

I think I already know the answer but I am still going to ask.. If it can be done, it would make my life  (and project) soo easy and complete.....

Would it be possible to connect a camera (for example something like this) to a pic.

What i need to do: when triggered (button on pic) it needs to make a picture and upload this picture to a DB.
Or, a link to a db and an ftp upload of the picture.....


trastikata

Quote from: Amateurtje on Jul 23, 2021, 05:40 PMI think I already know the answer but I am still going to ask.. If it can be done, it would make my life  (and project) soo easy and complete.....

Would it be possible to connect a camera (for example something like this) to a pic.

What i need to do: when triggered (button on pic) it needs to make a picture and upload this picture to a DB.
Or, a link to a db and an ftp upload of the picture.....

Everything can be done with the correct hardware and programming, but your question is overly simplified - meaning sounds like school home work project. Here's some points:

- Do you want to connect a point-and-shoot camera and emulate the push-to-shoot button, or you want to connect an imaging sensor?
- Uploading to DB - communication protocol? PC software?
- Ftp - again what hardware for connecting to the WWW - wireless IoT or LAN?
- etc.

As I said, narrow your question to specific problems. 
-

Amateurtje

It is not a school project. It is a setup of a system which still can be configured or changed. I thought it was very clear what i want to do. More demands I do not have...

the system must make a picture of a moving vehicle..  We have a pic-based timing system that detects the vehicle. A picture of the side of the fast moving vehicle must be made and thsi must be placed in a online Maria db.. This will be done through a GPRS card or a mobile wifi dongle..

With the part of cummonicating with the DB, I have experience, so that is not the biggest part of this question..

Nexessary hardware can be made or bought..  Why may a question not be simple and general to be discussed?

Quote- Do you want to connect a point-and-shoot camera and emulate the push-to-shoot button, or you want to connect an imaging sensor?

if the camera can be activated fast enough to make a picture, it can just be pointed and make a picture of the passing car. So, better question is: what can I best use?? What gives the clearest picture ? I think a push to shoot device...

QuoteUploading to DB - communication protocol? PC software?
Preferably it will be uplaoded to the db directly, not via a pc. Protocal can decided but in the past I had a project that just posted data to php files through AT commands to the GPRS card.. If the same can be done...

Quote- Ftp - again what hardware for connecting to the WWW - wireless IoT or LAN?
If LAN is necassary, it can be done also but we have to place a mobile router... So preferanbly directly to a GPRS card...





TimB


There are Cameras that you can connect and take photos. You can then download the image as a Jpg over TTL Usart and once you have it, send it any way you want.

I started on a miniature security camera that saved the image to an SD card back around 2010.

Gabi wrote the code to do the collection of data.


top204

I, personally, think for that type of application, it would be better to use a cheap Android handset, and write the control in Python.

I dislike Python, but it is closer to BASIC than C++, or the dreadful Java or C#.

The handset has the camera, the SD card, the bluetooth or wifi for connections, and the speed, and has a good graphic LCD for a GUI. The inexpensive handsets are a good platform and would, probably, cost less than building it all with a microcontroller, because all you need is already there in a single case. :-)

That may be a thought for you as well Tim?

 

Amateurtje

To learn another language, I do not have the time  and honestly the energy.. Picbasic, B4A, Vb.net is enough.. and even with Android(B4A) I am not sure if the timing part of this project would have the accuracy I require...

I also do not need a nice grafic interface while the picture does not need to be displayed. The GPRS and/or Wifi (ESP8266) connection I have already working with the pic as serial communication...

Therefore the serialisation part of a picture then would be the biggest mystery...  And to save the picture to the SD...

If you say that it is not possible in picbasic, than that is the case and I have to live with it... For my system I might have an alternative methode (the picture is for recognition but maybe then i go the direction of RFID...) However, a picture had the preference.....

top204

It is definately possible with Positron, but for a fast moving object to be photographed, it will probably require a PIC24 or dsPIC33 device.

The SD FAT saving, and sending the data is the simple part, the more involved part is the capturing of the image with enough resolution and speed.

normnet

#7
My 2015 camera project was a OV7670 displaying on a 320 x 240 GLCD with a 140 MHz PIC24EP128GP202 and port expander.   The camera data leads were connected to the display for viewing.  The OV7670 is .3 megapixel however I see there are now 5 megapixels camera's available. 

Amateurtje

being free in the choice, what would be the best? PIC24 or dsPIC33... I am open for making the jump.... Is there a development board of set of one of these PICs to start/test this project?

normnet

Quote from: Amateurtje on Jul 27, 2021, 03:12 PMbeing free in the choice, what would be the best? PIC24 or dsPIC33... I am open for making the jump.... Is there a development board of set of one of these PICs to start/test this project?

The dsPIC33CK series runs at 200 MHz however is surface mount.  A word of caution a camera project is not for the faint of heart as I don't know of a development board or Positron code examples for it.  Hopefully the camera has the ability to capture one image and clock its data out a little slower than would be required for video.

Yasin

About 10 years ago. We did an automation job for one of our customers. Everything was working perfectly. I used MCUs PIC18F452. Compiler positron(proton). I built the PC software with VB6.0. The customer controls 13 pumps at remote locations (a complete scada). The system was making remote communication with a 9600 baud RF modem. Five months later, a theft occurred. At the time of the incident, the computer received the security alarm information and the central alarm system was alerted. Until the security guards got ready and left (more than 10km away), there was a theft. Then my customer asked to add a camera to the system. I said that this is not rational with radio communication. Also, there was no GSM network in remote areas. My client was insistent because he wanted to do this business with a small budget. I did a study on it and found a color camera with RS485 hardware. I integrated it into the system. As soon as the motion sensor is activated or when a request is received from the center, the jpeg camera takes the photo. It was sending it to the central PC. The PC would save this photo by naming it date, time and location information and display it on the screen. Depending on the resolution set, the sending time of the photo was between 3 and 19 seconds.
Note; Even though it is very old, the system is still active.

If you want to work with such a camera, I can search the old codes in the archive.

Amateurtje

Hi yasin,

That would be great!! it has really a lot of simularities with my project..

I can even start with appr. the same hardware and software and start working from there.  I see you like the smae buidling blocks as i do :)..

Yasin

It was the camera.

It was the datasheet (protocol)

My own test interface using VB6.0

Original camera program in case it is not found.

5 seconds TOT of the same sdk


This is the camera-related piece of code.
                            RS485_EN = 1                                                            'RS485 portu gönderme modunda
                            Wait1 = 300                                                            'timeout süresi
                            Snapshot_Size = 0
                            Data_Packages = 0
                            Data_Packages_Size = 128                                                'Kameradan istenecek datapaketi boyutu
                            DelayMS 2
                            SerOut RS485_OUT,6,["UQ",0,160,"#"]                                    'Resim kalite ayarı
                            DelayMS 20
                            If OPCODE = 18 Then                                                    'Resmi yakala
                                SerOut RS485_OUT,6,["UH",0,"1",Data_Packages_Size,"#"]
                            ElseIf OPCODE = 19 Then   
                                SerOut RS485_OUT,6,["UH",0,"2",Data_Packages_Size,"#"]
                            ElseIf OPCODE = 20 Then
                                SerOut RS485_OUT,6,["UH",0,"3",Data_Packages_Size,"#"]
                            EndIf
                            DelayMS 100
                            RS485_EN = 0
                            SerIn RS485_IN,6,2000,RS485_TIMEOUT_CAM,[Wait("UR")]                   
                            SerIn RS485_IN,6,100,RS485_TIMEOUT_CAM,[JPEG_CAM_ID,Snapshot_Size,Data_Packages]    'Yakalanan resmin boyutunu öğren
                            Print Cls
                            Print At 0,0,Dec Snapshot_Size,"/",Dec Data_Packages                    'Ekranda Resim boyutunu ve parça sayısını göster
                            Clear JPEGDATA
                            JPEG_Parts_Count = 1
                            JPEG_LEN = 0
                            JPEG_SIZE = 0
                            DelayMS 900
                            RCV_RS485_DATA_CAM_REQ:                                                'Sırasıyla parçaları istek yap
                                RS485_EN = 1
                                DelayMS 20
                                SerOut RS485_OUT,6,["UE",0,JPEG_Parts_Count,"#"]
                                RS485_EN = 0
                            RCV_RS485_DATA_CAM:
                                SerIn RS485_IN,6,Wait1,RS485_TIMEOUT_CAM_BUF,[Str JPEGDATA \139]
                            RS485_TIMEOUT_CAM_BUF:
                                OPCODE = 18
                                DATA_BUFFER[1] = GROUP_ID
                                DATA_BUFFER[2] = STATION_ID
                                DATA_BUFFER[3] = $00
                                DATA_BUFFER[4] = OPCODE.LowByte
                                DATA_BUFFER[5] = OPCODE.HighByte
                                LENGTH = 5
                                For I = 0 To Data_Packages_Size - 1
                                    DATA_BUFFER[I + 6] = JPEGDATA[I + 11]
                                Next
                                LENGTH = LENGTH + I
                                DATA_BUFFER[0] = LENGTH + 1                                                'Length 0 dan başladığı için kendisinide uzunluğa dahil etmek için + 1
                                For J = 0 To LENGTH
                                    USART1_DATA[J] = DATA_BUFFER[J]
                                Next J
                                LENGTH_OFFSET = 0
                                CRC16
                                HSerOut ["$RF"]
                                For J = 0 To LENGTH
                                    HSerOut [USART1_DATA[J]]
                                Next J
                                HSerOut [CRC_16,"END",13,10]
                                GoSub CLR_WDT
                                DelayMS 1000
                                Inc JPEG_Parts_Count
                                If JPEG_Parts_Count = Data_Packages Then
                                    Data_Packages_Size = Snapshot_Size - (Data_Packages_Size * (Data_Packages - 1))
                                    GoTo RCV_RS485_DATA_CAM_REQ
                                ElseIf JPEG_Parts_Count < Data_Packages Then
                                    GoTo RCV_RS485_DATA_CAM_REQ
                                EndIf                           
                            RS485_TIMEOUT_CAM:
                                SEND_REQUEST = 1
                                OPCODE = 10

Not giving the whole project.
The first reason is very difficult to understand because it has a very comprehensive content.
The second reason is that without all the hardware it will fail and will not work as expected.
Third reason, since the project belongs to a commercial product, it would not be ethical for me to share the entire workplace.

Amateurtje

Completely logical..

I am going to dive into it.. Thanks a lot!!

I hope I may ask quesntions when working on it  :)


charliecoutas

Forgive me if this is a daft question, but the JPEG compressed image can't be displayed on anything unless that device understands the JPEG format? In other words, can you do anything with the photo apart from sending it somewhere else?

Charlie

top204

That look like a good camera with a serial interface for communicating with it.

They normally have a combination of I2C and a strange interface of pulses and analogue values coming out of it.

It must have an internal RAM buffer to store the camera image, ready to download. Is it only in jpg format when downloaded or can the raw image be downloaded?

Amateurtje

Small issue however with the camera: I can not find it anymore to buy it... But I am sure I will find an alternative.

For testing I was thinking about buying this:camera as TTL version. Or should I choose the RS485?  Do you think this is usefull?

As final camera I will search for a camera wit hthe same communication but with real housing etc...



Yasin

My English is very poor. I am sorry for this. I support what I wrote with google translate. Sorry if there is any misunderstanding.

The data obtained from the jpeg camera is completely jpeg image data.
Transactions are happening now.
-The size of the data you want to get from the camera at once is set.
-Adjusting the image quality (compression ratio) of the camera.
-The current image is captured at the desired resolution. (resolutions supported by the standard camera)
-According to the packet data size we set, it is learned how many pieces of packets will be transferred from the camera.
-These packages are stored in order and moved to the desired location. This process continues until all packages are finished.
-Jpeg image data is obtained by extracting crc and opcodes on the computer where all data is transmitted. Then, these data are saved in the jpg extension file produced on the computer as an empty one. Thus, the picture is formed.

Yasin

It's the same inside the camera I gave earlier. Don't be fooled by the box. The reason why I prefer RS485. There were 1 RS232 and 1 RS485 ports in the hardware. Since the RF modem is connected to RS232, I used the RS485 port to the camera. The choice is entirely up to you. Do not use any level converters if you want, use them directly as TTL. It's entirely up to you. I had supplied the sample camera as RS232. I connected it directly to the serial port of the computer. First I understood the camera with its own test software. Then I made my own test software and ran it without using a ready-made DLL file.

charliecoutas

To rephrase my question: are there cameras that allow you to fiddle around with the "image"? As Les hinted at, is there a raw image that can be processed without going into the complex world of JPEG?

Charlie