除非你想重订摄影机的部件,否则这必须是一个两步过程。 您might 能够从照相机中取出并直接处理,但我的猜测是,在不出现重大业绩问题的情况下,不可能这样做。
Instead, the first step is going to be to change the preview in real-time to show hue + saturation changes. To do this, you can use ColorFilter
widgets which wrap the preview widget. You re going to need to set these ColorFilters to perform the manipulation you d like; I d recommend looking at the Color Filter Generator pub package which includes the math for a bunch of different matrices including hue, saturation, brightness.
这里的一个例子是,你可以 past到dartpad.dev,看看它所看的情况。 但是,这个理论家是,使用<代码>hueMatrix和生成我随后转至图像Filter物体的矩阵方法的Im。 如果你想要的话,你甚至可以把使ShueMatrix和饱和Matrix功能合并为一种功能,但我可以让你完成这项工作。 比如,Im将过滤器应用到文字上,但对于照相机的预约来说,它应当做到同样。
import package:flutter/material.dart ;
import dart:math ;
// from https://github.com/hsbijarniya/colorfilter_generator
List<double> hueMatrix(double value) {
value = value * pi;
if (value == 0) {
return [
1,
0,
0,
0,
0,
0,
1,
0,
0,
0,
0,
0,
1,
0,
0,
0,
0,
0,
1,
0,
];
}
var cosVal = cos(value);
var sinVal = sin(value);
var lumR = 0.213;
var lumG = 0.715;
var lumB = 0.072;
return List<double>.from(<double>[
(lumR + (cosVal * (1 - lumR))) + (sinVal * (-lumR)),
(lumG + (cosVal * (-lumG))) + (sinVal * (-lumG)),
(lumB + (cosVal * (-lumB))) + (sinVal * (1 - lumB)),
0,
0,
(lumR + (cosVal * (-lumR))) + (sinVal * 0.143),
(lumG + (cosVal * (1 - lumG))) + (sinVal * 0.14),
(lumB + (cosVal * (-lumB))) + (sinVal * (-0.283)),
0,
0,
(lumR + (cosVal * (-lumR))) + (sinVal * (-(1 - lumR))),
(lumG + (cosVal * (-lumG))) + (sinVal * lumG),
(lumB + (cosVal * (1 - lumB))) + (sinVal * lumB),
0,
0,
0,
0,
0,
1,
0,
]).map((i) => i.toDouble()).toList();
}
// from https://github.com/hsbijarniya/colorfilter_generator
List<double> saturationMatrix(double value) {
value = value * 100;
if (value == 0) {
return [
1,
0,
0,
0,
0,
0,
1,
0,
0,
0,
0,
0,
1,
0,
0,
0,
0,
0,
1,
0,
];
}
var x =
((1 + ((value > 0) ? ((3 * value) / 100) : (value / 100)))).toDouble();
var lumR = 0.3086;
var lumG = 0.6094;
var lumB = 0.082;
return List<double>.from(<double>[
(lumR * (1 - x)) + x,
lumG * (1 - x),
lumB * (1 - x),
0,
0,
lumR * (1 - x),
(lumG * (1 - x)) + x,
lumB * (1 - x),
0,
0,
lumR * (1 - x),
lumG * (1 - x),
(lumB * (1 - x)) + x,
0,
0,
0,
0,
0,
1,
0,
]).map((i) => i.toDouble()).toList();
}
void main() {
runApp(MyApp());
}
class MyApp extends StatefulWidget {
@override
State<MyApp> createState() => _MyAppState();
}
class _MyAppState extends State<MyApp> {
double hue = 0;
double saturation = 0;
@override
Widget build(BuildContext context) {
return MaterialApp(
home: Scaffold(
body: Column(
mainAxisAlignment: MainAxisAlignment.center,
mainAxisSize: MainAxisSize.max,
crossAxisAlignment: CrossAxisAlignment.center,
children: [
MyWidget(hue: hue, saturation: saturation),
Text("Hue:"),
Slider(
value: hue / 2 + .5,
onChanged: (val) => setState(() => hue = val * 2 - 1),
),
Text("Saturation:"),
Slider(
value: saturation / 2 + .5,
onChanged: (val) => setState(() => saturation = val * 2 - 1),
)
],
),
),
);
}
}
class MyWidget extends StatelessWidget {
final double hue;
final double saturation;
const MyWidget({super.key, required this.hue, required this.saturation});
@override
Widget build(BuildContext context) {
final theme = Theme.of(context);
return ColorFiltered(
colorFilter: ColorFilter.matrix(hueMatrix(hue)),
child: ColorFiltered(
colorFilter: ColorFilter.matrix(
saturationMatrix(saturation),
),
child: Text(
Hello, World! ,
style: theme.textTheme.headlineMedium!
.copyWith(color: theme.primaryColor),
),
),
);
}
}
这是你问题的第一个部分;现在,你们有一个预告,显示有饱和、hu的录像,或者任何其他应用。
The second part is going to be a lot more dependent on a bunch of other factors such as which format you re recording, what you re doing with the video etc. But basically, once you call stopVideoRecording on the camera, you ll be given a XFile object which contains the data from the video. Should be similar for if you re taking a picture.
您也许能够利用一个原始资料,例如tapioca<>, 供当时使用的录像,以添加正确的字塔,但我觉得自己没有足够功能。 如果是这样,你很可能需要包括约3个特定方和甲状腺素(如果你重新使用这种物质的话,是SOS)包,然后从冲碎打到洗 actual实际的胡 &;饱和任何其它东西,然后等待处理,然后就与档案做任何其它事情。
对于图像而言,除了可能更容易获得的原始材料外,你还拥有类似的过程,而且如果你能够照相操作——>:编辑可能做成像,因为它似乎支持采用一种彩色矩阵。