In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-23 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >
Share
Shulou(Shulou.com)06/01 Report--
Most people do not understand the knowledge points of this article "python how to achieve DIY camera", so the editor summarizes the following content, detailed content, clear steps, and has a certain reference value. I hope you can get something after reading this article. Let's take a look at this "python how to achieve DIY camera" article.
Camera (CAMERA or WEBCAM), also known as computer camera, computer eye, surveillance camera, etc., is a kind of video input device, which is widely used in video conference, security system, image acquisition system, environmental monitoring, industrial field process control and so on. This experiment uses TPYBoard V102 and PTC06 serial camera module DIY a simple camera.
1. Equipment used:
L TPYBoard v102 1
L 1 PTC06 serial camera module
L some DuPont lines
L TF card 1
L download 1 data cable
Introduction to 2.TPYBoard v102:
The TPYBoardv102 master chip adopts the kernel of STM32F405,M4, the highest running speed of 168MHZ, the RAM of Flash,192KB of 1024KB, the built-in SD card slot, and the memory card which supports up to 8G memory. Four LED lights and one accelerometer on board. TPYBoard V102 board has 30 general GPIO interfaces, 2 SPI interfaces, 2 CAN interfaces, 2 I2C interfaces, 5 USART interfaces, 2 ADC interfaces (precision 12bit), 2 DAC interfaces and 1 SWD interface. It can be connected with most commonly used sensor modules.
3. Brief introduction of PTC06 serial camera module:
PTC06 serial camera module is an industrial image acquisition and processing module which integrates image acquisition, shooting control, data compression and serial port transmission. Its built-in high-performance digital signal processing chip realizes the high-proportional compression of the original image. The product image output adopts the standard JPEG format, which can be easily compatible with all kinds of image processing software, and the 3-wire TTL level UART communication interface can be easily connected with single-chip microcomputer or other microprocessors.
The default baud rate is 115200, and other optional baud rates are 9600, 19200, 38400 and 57600.
In the application of serial port control to take photos and read static pictures, only the four signal lines of GND,RX,TX,VCC are needed. If you want to output analog video applications, you need to send the CVBS signal. Note: TX and RX are 3.3v TTL level signals.
4. Connection method:
5. The experimental procedure.
Basic principle: TPYboard V102 connects with the serial camera module (PTC06) through the serial port, takes pictures through the key control module, and saves it to the TF card. After power up, wait for the green light on the ToyBoard V102 board to show that the camera module has been initialized. Press the USR key to control the camera to take pictures, and the blue light will flash, indicating that the picture data is being transmitted. After waiting for the blue light to go off, the transmission is complete. Press the rst key to reload the TF card on the board. Open the TF card and you will see a newly generated jpeg file.
6. Source code:
"# TPYBoard v102 drives serial camera PTC06 to take photos and save them to TF card #-- # author: Shandong radish Electronic Technology Co., Ltd. # time: March 15, 2018"import pybfrom pyb import UART" The basic process of taking pictures in Switch-1. Clear the image cache 2. Send photo command 3. Get the length of the picture 4. According to the length of the instructions used to read the image data and the returned data format-reset 0x56 0x00 0x26 0x00 returns 0x76 0x00 0x26 0x00 + DSP version information + Init end---- empty image cache 0x56 0x00 0x36 0x01 0x02 returns 0x76 0x00 0x36 0x00 0x00Murray- -Photo command 0x56 0x00 0x36 0x01 0x00 returns 0x76 0x00 0x36 0x00 0x00 color-read the length of the picture 56 00 34 01 00 returns 0x76 0x00 0x34 0x00 0x04 0x00 0x00 XX YY (XX is high byte YY is low byte)-read picture data 0x56 0x00 0x32 0x0C 0x00 0x0A 0x00 0x00 AA BB 0x00 0x00 XX YY 0x00 0xFFAA BB: starting address (first high byte, then low byte. Must be a multiple of 8) XX YY: the data length of this read (first high-order bytes, then low-order bytes) returns 76.00 3200 FF D8. FF D9 76 00 32 00 (the complete JPEG image file ends with FF D8) "#-Command-#initcmd=b'\ x56\ X00\ x26\ x00' # reset instruction clearcmd=b'\ x56\ x36\ X01\ x02' # clear the cache photocmd=b'\ x56\ x36\ X01\ x00' # Photo lengthcmd=b'\ X56\ X00\ X34\ X01\ x00' # get the picture length The degree readcmd=b'\ x56\ x00\ x32\ x0C\ X00\ X0A\ x00\ x00 # gets the picture data returned by responseCmd=b'\ x76\ x00\ x32\ x00\ x00marker #-- # isFlag=0# identifies whether the isPhoto=0# logo is initialized or sends the photo command num=1f_name='/sd/photo%s .jpeg'# saved file name number of bytes per read by nBytes=512# #-# uart=UART (4jpeg 115200 Timeout=100) # Serial port 4 TX-X1 RX-X2#- converts decimal to hexadecimal byte array-# def convert_Data (num): if num > 255: num_h=hex (num) if len (num_h) = 5: if data [0] = = 118:#0x76 if data [2] = = 54:#0x36 If isPhoto==0: # Clean cache returns print ('- clear buffer ok----') isPhoto=1 uart.write (photocmd) else: # return print ('- taking pictures ok----') uart.write (lengthcmd) if data [2] = 52:#0x34 print ('photo length:') after taking photos Data [7],'-' Data [8]) tlen=data [7] * 256+data [8] t_c=tlen//nBytes t_y=tlen%nBytes add=0 # 256 = [0x01meme0x00] 512 = [0x02record0x00] length=convert_Data (nBytes) Name=f_name% str (num) print ('filename:' Name) for i in range (0gramme): add=convert_Data (i*nBytes) # write revdata=get_photo (add,length) if revdataoby0: f=open (name) every 512 bytes 'a') f.write (revdata) f.close () pyb.LED (4). Toggle () print ('-' I) pyb.delay (100,100) add=convert_Data (t_c*nBytes) revdata=get_photo (add,convert_Data (tweey)) if revdata0: f=open (name) 'a') f.write (revdata) f.close () pyb.LED (3). Off () pyb.LED (4). Off () pyb.delay (100) print (' * =) sw.callback (test) else: print ('- data length error-') these are the contents of this article on "how python implements a DIY camera" I believe we all have a certain understanding. I hope the content shared by the editor will be helpful to you. If you want to know more about the relevant knowledge, please pay attention to the industry information channel.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.