Skip to content

Commit

Permalink
delete web select
Browse files Browse the repository at this point in the history
Change-Id: Idddcdda0d0f33a93e84c91539ecf5af204a1613d
yuchuan.he committed Oct 12, 2024
1 parent fd2494b commit b3570dd
Showing 1 changed file with 17 additions and 19 deletions.
36 changes: 17 additions & 19 deletions samples/dwa_dpu_encode/web/ui/src/components/VideoDisplay/VideoDisplay.js
100644 → 100755
Original file line number Diff line number Diff line change
@@ -20,21 +20,21 @@ const VideoDisplay = () => {
const canvasCtx = canvas.getContext('2d');
const canvasWidth = canvas.width;
const canvasHeight = canvas.height;

// 清除canvas内容
canvasCtx.clearRect(0, 0, canvasWidth, canvasHeight);

// 计算最适合的缩放比例
const scale = Math.min(canvasWidth / img.width, canvasHeight / img.height);

// 计算绘制图像的尺寸
const imgDrawWidth = img.width * scale;
const imgDrawHeight = img.height * scale;

// 计算绘制图像的位置以使其居中
const imgDrawX = (canvasWidth - imgDrawWidth) / 2;
const imgDrawY = (canvasHeight - imgDrawHeight) / 2;

// 绘制图像
canvasCtx.drawImage(img, imgDrawX, imgDrawY, imgDrawWidth, imgDrawHeight);
};
@@ -89,15 +89,15 @@ const VideoDisplay = () => {

const handleDisplayType = (event) => {
setDisplayType(event.target.value)
const request_json = {
"type": event.target.value
const request_json = {
"type": event.target.value
}
fetch(serverIpWithPort+`/display-type-dpu`, {
method: 'PUT',
fetch(serverIpWithPort + `/display-type-dpu`, {
method: 'PUT',
headers: {
'Content-Type': 'application/json',
},
body: JSON.stringify(request_json),
body: JSON.stringify(request_json),
})
.then(response => response.json())
.then(result => {
@@ -110,20 +110,18 @@ const VideoDisplay = () => {
alert('Request failed: ' + error.message); // Show an alert with the failure message
});

}
}

return (
<div className='VideoDisplay'>

<div>
<label>码流选择:</label>
<div>
<label>码流选择:</label>

<Select className='DisplayTypeSelector' value={displayType} onChange={handleDisplayType}>
<MenuItem value={0}> 原图+深度图 </MenuItem>
<MenuItem value={1}> DWA+深度图 </MenuItem>
<MenuItem value={2}> 仅深度图 </MenuItem>
</Select>
</div>
<Select className='DisplayTypeSelector' value={displayType} onChange={handleDisplayType}>
<MenuItem value={0}> 原图+深度图 </MenuItem>
</Select>
</div>

<div className='CanvasContainer' id='canvasContainer'>
<canvas ref={canvasRef} ></canvas>

0 comments on commit b3570dd

Please sign in to comment.