Skip to content

Commit

Permalink
update examples, version
Browse files Browse the repository at this point in the history
Signed-off-by: huangziyi <[email protected]>
  • Loading branch information
MrThanlon committed Jul 10, 2024
1 parent b3f3593 commit b5bb333
Show file tree
Hide file tree
Showing 160 changed files with 4,746 additions and 30,556 deletions.
6 changes: 3 additions & 3 deletions cmake/QtCreatorIDEBranding.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -25,15 +25,15 @@ set(IDE_ICON_PATH "")
set(IDE_LOGO_PATH "")

# OPENMV-DIFF #
set(IDE_VERSION "4.0.6")
set(IDE_VERSION "4.0.7")
set(IDE_VERSION_COMPAT "${IDE_VERSION}")
set(IDE_VERSION_DISPLAY "${IDE_VERSION}")
set(IDE_AUTHOR "Canaan Inc.")
set(IDE_COPYRIGHT_YEAR_FOUNDED "2013")
set(IDE_COPYRIGHT_YEAR "2024")
set(IDE_SETTINGSVARIANT "CanMV")
set(IDE_DISPLAY_NAME "CanMV IDE 4")
set(IDE_DISPLAY_NAME "CanMV IDE K230")
set(IDE_ID "canmvide")
set(IDE_CASED_ID "CanMVIDE4")
set(IDE_CASED_ID "CanMVIDEK230")
set(IDE_BUNDLE_IDENTIFIER "com.canaan-creative.${IDE_ID}")
# OPENMV-DIFF #
8 changes: 4 additions & 4 deletions dist/installer/ifw/config/config-windows.xml.in
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
<?xml version="1.0"?>
<Installer>
<Name>CanMV IDE 4</Name>
<Name>CanMV IDE K230</Name>
<Version>{version}</Version>
<Title>CanMV IDE 4</Title>
<Title>CanMV IDE K230</Title>
<Publisher>Canaan Inc.</Publisher>
<ProductUrl>https://www.canaan.io</ProductUrl>

<MaintenanceToolName>CanMVIDEUninst</MaintenanceToolName>
<TargetDir>@ApplicationsDir@/CanMV IDE 4</TargetDir>
<StartMenuDir>CanMV IDE 4</StartMenuDir>
<TargetDir>@ApplicationsDir@/CanMV IDE K230</TargetDir>
<StartMenuDir>CanMV IDE K230</StartMenuDir>
<ControlScript>controlscript.qs</ControlScript>
</Installer>
Original file line number Diff line number Diff line change
Expand Up @@ -83,11 +83,11 @@ Component.prototype.createOperations = function()
{
component.addOperation( "CreateShortcut",
component.qtCreatorBinaryPath,
"@StartMenuDir@/CanMV K230 IDE.lnk",
"@StartMenuDir@/CanMV IDE K230.lnk",
"workingDirectory=@homeDir@" );
component.addOperation( "CreateShortcut",
component.qtCreatorBinaryPath,
"@DesktopDir@/CanMV K230 IDE.lnk",
"@DesktopDir@/CanMV IDE K230.lnk",
"workingDirectory=@homeDir@" );
component.addOperation( "CreateShortcut",
"@TargetDir@/CanMVIDEUninst.exe",
Expand All @@ -104,8 +104,8 @@ Component.prototype.createOperations = function()
component.addOperation( "CreateDesktopEntry",
"CanMV-openmvide.desktop",
"Type=Application\n" +
"Name=CanMV IDE 4\n" +
"GenericName=CanMV IDE 4\n" +
"Name=CanMV IDE K230\n" +
"GenericName=CanMV IDE K230\n" +
"Comment=The IDE of choice for CanMV Cam Development.\n" +
"Exec=" + component.qtCreatorBinaryPath + " %F\n" +
"Icon=CanMV-canmvide\n" +
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
<item>
<widget class="QCheckBox" name="launchQtCreatorCheckBox">
<property name="text">
<string>Launch CanMV IDE</string>
<string>Launch CanMV IDE K230</string>
</property>
<property name="checked">
<bool>true</bool>
Expand Down
215 changes: 110 additions & 105 deletions share/qtcreator/examples/01-Media/acodec.py
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,11 @@
#
# You can collect raw data and encode it into g711 or decode it into raw data output.


from media.pyaudio import * #导入pyaudio模块,用于采集和播放音频
import os
from mpp.payload_struct import * #导入payload模块,用于获取音视频编解码类型
from media.media import * #导入media模块,用于初始化vb buffer
from media.pyaudio import * #导入pyaudio模块,用于采集和播放音频
import media.g711 as g711 #导入g711模块,用于g711编解码
from mpp.payload_struct import * #导入payload模块,用于获取音视频编解码类型
import os

def exit_check():
try:
Expand All @@ -25,126 +24,132 @@ def encode_audio(filename, duration):
CHANNELS = 2 #设置声道数
RATE = 44100 #设置采样率

p = PyAudio()
p.initialize(CHUNK) #初始化PyAudio对象
enc = g711.Encoder(K_PT_G711A,CHUNK) #创建g711编码器对象
media.buffer_init() #vb buffer初始化

enc.create() #创建编码器
#创建音频输入流
stream = p.open(format=FORMAT,
channels=CHANNELS,
rate=RATE,
input=True,
frames_per_buffer=CHUNK)

frames = []
#采集音频数据编码并存入列表
for i in range(0, int(RATE / CHUNK * duration)):
frame_data = stream.read() #从音频输入流中读取音频数据
data = enc.encode(frame_data) #编码音频数据为g711
frames.append(data) #将g711编码数据保存到列表中
if exit_check():
break

stream.stop_stream() #停止音频输入流
stream.close() #关闭音频输入流
p.terminate() #释放音频对象
enc.destroy() #销毁g711音频编码器

#将g711编码数据存入文件中
with open(filename,mode='w') as wf:
wf.write(b''.join(frames))

media.buffer_deinit() #释放vb buffer
try:
p = PyAudio()
p.initialize(CHUNK) #初始化PyAudio对象
enc = g711.Encoder(K_PT_G711A,CHUNK) #创建g711编码器对象
MediaManager.init() #vb buffer初始化

enc.create() #创建编码器
#创建音频输入流
stream = p.open(format=FORMAT,
channels=CHANNELS,
rate=RATE,
input=True,
frames_per_buffer=CHUNK)

frames = []
#采集音频数据编码并存入列表
for i in range(0, int(RATE / CHUNK * duration)):
frame_data = stream.read() #从音频输入流中读取音频数据
data = enc.encode(frame_data) #编码音频数据为g711
frames.append(data) #将g711编码数据保存到列表中
if exit_check():
break
#将g711编码数据存入文件中
with open(filename,mode='w') as wf:
wf.write(b''.join(frames))
stream.stop_stream() #停止音频输入流
stream.close() #关闭音频输入流
p.terminate() #释放音频对象
enc.destroy() #销毁g711音频编码器
except BaseException as e:
print(f"Exception {e}")
finally:
MediaManager.deinit() #释放vb buffer

def decode_audio(filename):
wf = open(filename,mode='rb') #打开g711文件
FORMAT = paInt16 #设置音频chunk值
CHANNELS = 2 #设置声道数
RATE = 44100 #设置采样率
CHUNK = int(RATE/25) #设置音频chunk值

p = PyAudio()
p.initialize(CHUNK) #初始化PyAudio对象
dec = g711.Decoder(K_PT_G711A,CHUNK) #创建g711解码器对象
media.buffer_init() #vb buffer初始化

dec.create() #创建解码器
try:
wf = open(filename,mode='rb') #打开g711文件
p = PyAudio()
p.initialize(CHUNK) #初始化PyAudio对象
dec = g711.Decoder(K_PT_G711A,CHUNK) #创建g711解码器对象
MediaManager.init() #vb buffer初始化

#创建音频输出流
stream = p.open(format=FORMAT,
channels=CHANNELS,
rate=RATE,
output=True,
frames_per_buffer=CHUNK)
dec.create() #创建解码器

stream_len = CHUNK*CHANNELS*2//2 #设置每次读取的g711数据流长度
stream_data = wf.read(stream_len) #从g711文件中读取数据
#创建音频输出流
stream = p.open(format=FORMAT,
channels=CHANNELS,
rate=RATE,
output=True,
frames_per_buffer=CHUNK)

#解码g711文件并播放
while stream_data:
frame_data = dec.decode(stream_data) #解码g711文件
stream.write(frame_data) #播放raw数据
stream_len = CHUNK*CHANNELS*2//2 #设置每次读取的g711数据流长度
stream_data = wf.read(stream_len) #从g711文件中读取数据
if exit_check():
break

stream.stop_stream() #停止音频输入流
stream.close() #关闭音频输入流
p.terminate() #释放音频对象
dec.destroy() #销毁解码器
wf.close() #关闭g711文件

media.buffer_deinit() #释放vb buffer
#解码g711文件并播放
while stream_data:
frame_data = dec.decode(stream_data) #解码g711文件
stream.write(frame_data) #播放raw数据
stream_data = wf.read(stream_len) #从g711文件中读取数据
if exit_check():
break
stream.stop_stream() #停止音频输入流
stream.close() #关闭音频输入流
p.terminate() #释放音频对象
dec.destroy() #销毁解码器
wf.close() #关闭g711文件

except BaseException as e:
print(f"Exception {e}")
finally:
MediaManager.deinit() #释放vb buffer

def loop_codec(duration):
CHUNK = int(44100/25) #设置音频chunk值
FORMAT = paInt16 #设置采样精度
CHANNELS = 2 #设置声道数
RATE = 44100 #设置采样率

p = PyAudio()
p.initialize(CHUNK) #初始化PyAudio对象
dec = g711.Decoder(K_PT_G711A,CHUNK) #创建g711解码器对象
enc = g711.Encoder(K_PT_G711A,CHUNK) #创建g711编码器对象
media.buffer_init() #vb buffer初始化

dec.create() #创建g711解码器
enc.create() #创建g711编码器

#创建音频输入流
input_stream = p.open(format=FORMAT,
channels=CHANNELS,
rate=RATE,
input=True,
frames_per_buffer=CHUNK)

#创建音频输出流
output_stream = p.open(format=FORMAT,
channels=CHANNELS,
rate=RATE,
output=True,
frames_per_buffer=CHUNK)

#从音频输入流中获取数据->编码->解码->写入到音频输出流中
for i in range(0, int(RATE / CHUNK * duration)):
frame_data = input_stream.read() #从音频输入流中获取raw音频数据
stream_data = enc.encode(frame_data) #编码音频数据为g711
frame_data = dec.decode(stream_data) #解码g711数据为raw数据
output_stream.write(frame_data) #播放raw数据
if exit_check():
break

input_stream.stop_stream() #停止音频输入流
output_stream.stop_stream() #停止音频输出流
input_stream.close() #关闭音频输入流
output_stream.close() #关闭音频输出流
p.terminate() #释放音频对象
dec.destroy() #销毁g711解码器
enc.destroy() #销毁g711编码器

media.buffer_deinit() #释放vb buffer
try:
p = PyAudio()
p.initialize(CHUNK) #初始化PyAudio对象
dec = g711.Decoder(K_PT_G711A,CHUNK) #创建g711解码器对象
enc = g711.Encoder(K_PT_G711A,CHUNK) #创建g711编码器对象
MediaManager.init() #vb buffer初始化

dec.create() #创建g711解码器
enc.create() #创建g711编码器

#创建音频输入流
input_stream = p.open(format=FORMAT,
channels=CHANNELS,
rate=RATE,
input=True,
frames_per_buffer=CHUNK)

#创建音频输出流
output_stream = p.open(format=FORMAT,
channels=CHANNELS,
rate=RATE,
output=True,
frames_per_buffer=CHUNK)

#从音频输入流中获取数据->编码->解码->写入到音频输出流中
for i in range(0, int(RATE / CHUNK * duration)):
frame_data = input_stream.read() #从音频输入流中获取raw音频数据
stream_data = enc.encode(frame_data) #编码音频数据为g711
frame_data = dec.decode(stream_data) #解码g711数据为raw数据
output_stream.write(frame_data) #播放raw数据
if exit_check():
break
input_stream.stop_stream() #停止音频输入流
output_stream.stop_stream() #停止音频输出流
input_stream.close() #关闭音频输入流
output_stream.close() #关闭音频输出流
p.terminate() #释放音频对象
dec.destroy() #销毁g711解码器
enc.destroy() #销毁g711编码器
except BaseException as e:
print(f"Exception {e}")
finally:
MediaManager.deinit() #释放vb buffer

if __name__ == "__main__":
os.exitpoint(os.EXITPOINT_ENABLE)
Expand Down
Loading

0 comments on commit b5bb333

Please sign in to comment.