-
Notifications
You must be signed in to change notification settings - Fork 29.7k
Closed
flutter/plugins
#4519Labels
P2Important issues not at the top of the work listImportant issues not at the top of the work listfound in release: 2.5Found to occur in 2.5Found to occur in 2.5found in release: 2.6Found to occur in 2.6Found to occur in 2.6has reproducible stepsThe issue has been confirmed reproducible and is ready to work onThe issue has been confirmed reproducible and is ready to work onp: cameraThe camera pluginThe camera pluginpackageflutter/packages repository. See also p: labels.flutter/packages repository. See also p: labels.waiting for PR to land (fixed)A fix is in flightA fix is in flight
Description
In the camera plugin, even though I have specified yuv420 as the imageFormatGroup, the data retrieved by startImageStream is the same as that of bgra8888.
Steps to Reproduce
- Execute
flutter runon the code sample - Looking at the log, there are some strange things going on, such as the byte size being too large, even though the format is yuv.
Expected results:
flutter: format: ImageFormatGroup.yuv420
flutter: planes: 2
flutter: bytes: 2088960
flutter: width: 1080
flutter: height: 1920
flutter: bytesPerRow: 1088
Actual results:
flutter: format: ImageFormatGroup.yuv420
flutter: planes: 1
flutter: bytes: 8355840
flutter: width: 1080
flutter: height: 1920
flutter: bytesPerRow: 4352
Code sample
import 'package:camera/camera.dart';
import 'package:flutter/material.dart';
void main() {
runApp(const MyApp());
}
class MyApp extends StatelessWidget {
const MyApp({Key? key}) : super(key: key);
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'Flutter Demo',
theme: ThemeData(
primarySwatch: Colors.blue,
),
home: const MyHomePage(),
);
}
}
class MyHomePage extends StatefulWidget {
const MyHomePage({Key? key}) : super(key: key);
@override
State<MyHomePage> createState() => _MyHomePageState();
}
class _MyHomePageState extends State<MyHomePage> {
CameraController? controller;
Future<void> init() async {
final cameras = await availableCameras();
if (cameras.isEmpty) return;
controller = CameraController(
cameras.first,
ResolutionPreset.veryHigh,
enableAudio: false,
imageFormatGroup: ImageFormatGroup.yuv420,
);
await controller!.initialize();
}
@override
void initState() {
init().then((_) {
setState(() {});
});
super.initState();
}
@override
void dispose() {
controller?.dispose();
super.dispose();
}
@override
Widget build(BuildContext context) {
return Scaffold(
body: controller == null ? Container() : CameraPreview(controller!),
floatingActionButton: FloatingActionButton(
onPressed: () {
controller?.startImageStream((image) {
print('format: ${image.format.group}');
print('planes: ${image.planes.length}');
print('bytes: ${image.planes.first.bytes.length}');
print('width: ${image.width}');
print('height: ${image.height}');
print('bytesPerRow: ${image.planes.first.bytesPerRow}');
});
},
child: const Icon(Icons.camera),
), // This trailing comma makes auto-formatting nicer for build methods.
);
}
}flutter doctor -v
[✓] Flutter (Channel stable, 2.5.3, on macOS 12.0.1 21A559 darwin-arm, locale ja-JP)
• Flutter version 2.5.3 at /Users/zuvola/Documents/Tools/flutter
• Upstream repository https://github.com/flutter/flutter.git
• Framework revision 18116933e7 (5 weeks ago), 2021-10-15 10:46:35 -0700
• Engine revision d3ea636dc5
• Dart version 2.14.4
[✓] Android toolchain - develop for Android devices (Android SDK version 31.0.0)
• Android SDK at /Users/zuvola/Library/Android/sdk
• Platform android-31, build-tools 31.0.0
• Java binary at: /Applications/Android Studio
Preview.app/Contents/jre/jdk/Contents/Home/bin/java
• Java version OpenJDK Runtime Environment (build 11.0.12+0-b1504.28-7817840)
• All Android licenses accepted.
[✓] Xcode - develop for iOS and macOS
• Xcode at /Applications/Xcode.app/Contents/Developer
• Xcode 13.1, Build version 13A1030d
• CocoaPods version 1.11.2
[✓] Chrome - develop for the web
• Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome
[✓] Android Studio
• Android Studio at /Applications/Android Studio Preview.app/Contents
• Flutter plugin can be installed from:
🔨 https://plugins.jetbrains.com/plugin/9212-flutter
• Dart plugin can be installed from:
🔨 https://plugins.jetbrains.com/plugin/6351-dart
• Java version OpenJDK Runtime Environment (build 11.0.12+0-b1504.28-7817840)
[✓] VS Code (version 1.62.2)
• VS Code at /Applications/Visual Studio Code.app/Contents
• Flutter extension version 3.28.0
[✓] Connected device (1 available)
• Chrome (web) • chrome • web-javascript • Google Chrome 96.0.4664.45
WillowWisp
Metadata
Metadata
Assignees
Labels
P2Important issues not at the top of the work listImportant issues not at the top of the work listfound in release: 2.5Found to occur in 2.5Found to occur in 2.5found in release: 2.6Found to occur in 2.6Found to occur in 2.6has reproducible stepsThe issue has been confirmed reproducible and is ready to work onThe issue has been confirmed reproducible and is ready to work onp: cameraThe camera pluginThe camera pluginpackageflutter/packages repository. See also p: labels.flutter/packages repository. See also p: labels.waiting for PR to land (fixed)A fix is in flightA fix is in flight