I am trying to retrieve the video format
Ex. my input video file is video.mpeg then I want format as mpeg
I used this function
double Format = cvGetCapturePrperty(capture,CV_CAP_PROP_FORMAT);
but it returns 0.000
Please help.
Thanks.
CV_CAP_PROP_FORMAT is not what you think. Check the documentation.
You are probably looking for:
double val = cvGetCaptureProperty( capture, CV_CAP_PROP_FOURCC );
char* fourcc = (char*) (&val);
Related
I am a beginner with Node-Red and I would like to read the data of a meter via modbus and then display it in float format
With Modbus-Read node I'm getting this data:
How can I to convert in a float number like 407.555
thanks in advance for the help
Update 06/11/2021: I'tryng to convert the array recived from modbus but the result is wrong.
I try tu use a function like this:
let pay = msg.payload;
const buf = Buffer.allocUnsafe(4);
buf.writeInt16BE(pay[0],2);
buf.writeInt16BE(pay[1],0);
msg.payload = buf.readFloatBE(0);
return msg;
In NodeRed if I add a debug I can read
0x1f85
0xb40
so is the same reading using a different modbus reader but the conversion in nodered with the function is 3.700156759202689e-32 and the value right is 2.18
I'm searching for a way to copy a BSON document to a buffer or into a file using the C-library libbson.
I think I'm missing something - any help is appreciated.
bson_as_canonical_extended_json exports BSON into UTF-8 without loss of information.
If you only need buffer data, you can use bson_get_data :
bson_t * bson = bson_new();
///// Fill with data
// Get data buffer
const char * data = reinterpret_cast<const char*>(bson_get_data(bson));
int length = bson->len;
I am working on a IOT project using MSP430F5529LP and CC3100Boost. The hardware is successfully connecting to the cloud and exchanging data. The response to the IOT devices is XML based. I am trying to parse the data. The following printf("\n%.*s\n", pch2-pch1-8, pch1 +8); extracts the data and prints to the console. Now in need to save this data to a variable. Here is my code snippet. The answer might be obvious, unfortunately I am failing to see it.
_i8 * databuffer;
char * pch0;
char * pch1;
char * pch2;
char data[7];
pch0 = strstr((char *)dataBuffer,"textResponse");
pch1 = strstr(pch0,"<text_1>");
pch2 = strstr(pch1,"</text_1>");
printf("\n%.*s\n", pch2-pch1-8, pch1 +8);
References:
Extract data between two delimiters
parsing the value in between two XML tags
MSP430G2121: looking for a xml library to parse xml text
Ensure that the data received is valid and of a length that will fit.
Print it to a string using sprintf() or equivalent function.
Print this string to the console with puts(the_string).
I need to know how to use the ICU4C version 52 C API to display the locale Currency Symbol and code. i.e. ($ - USD)
There is probably more than one way how to do this. Here is one, that I think should work (untested):
Get the number format and format the value using it:
UErrorCode success = U_ZERO_ERROR;
UNumberFormat *nf;
const char* myLocale = "fr_FR";
// get locale specific number format
nf = unum_open( UNUM_CURRENCY, myLocale, success );
// use it to format the value
UChar buf[100];
unum_formatDouble (nf, 10.0, buf, 100, NULL, &success);
// close the format handle
unum_close(nf);
Or, more directly, use ucurr_getName() with the UCURR_SYMBOL_NAME selector. You can also use ucurr_forLocale() or ucurr_forLocaleAndDate() to get the currency code without needing a formatter. Note that there can be multiple currencies for a locale.
I’m trying to use OpenCV to write a video file. I have a simple program that loads frames from a video file then accepts to save them
At first the cvCreateVideoWrite always return NULL. I got a answer from your group saying it returns separate images and to try to change the file name to test0001.png, this worked.
But now the cvWriteFrame function always fails, the code is
CString path;
path="d:\\mice\\Test_Day26_2.avi";
CvCapture* capture = cvCaptureFromAVI(path);
IplImage* img = 0;
CvVideoWriter *writer = 0;
int isColor = 1;
int fps = 25; // or 30
int frameW = 640; // 744 for firewire cameras
int frameH = 480; // 480 for firewire cameras
writer=cvCreateVideoWriter("d:\\mice\\test0001.png",CV_FOURCC('P','I','M','1'),
fps,cvSize(frameW,frameH),isColor);
if (writer==0)
MessageBox("could not open writter");
int nFrames = 50;
for(int i=0;i<nFrames;i++){
if (!cvGrabFrame(capture))
MessageBox("could not grab frame");
img=cvRetrieveFrame(capture); // retrieve the captured frame
if (img==0)
MessageBox("could not retrive data");
if (!cvWriteFrame(writer,img) )
MessageBox("could not write frame");
}
cvReleaseVideoWriter(&writer);
Try CV_FOURCC('D', 'I', 'V', 'X'), CV_FOURCC('f', 'f', 'd', 's') (with *.avi filename) or CV_FOURCC_DEFAULT (with *.mpg). Video writing is still quite messy in opencv >_>
I've seen many issues with writing video as well in OpenCV. I found intel iYUV format worked well for what I needed.
Was your library built with HAVE_FFMPEG defined?
If it wasn't,you might need to recompile opencv with that option.You should see something like this in the configure step:
...
Video I/O--------------
Use QuickTime no
Use xine no
Use ffmpeg: yes
Use v4l yes
...
If you don't have ffmpeg,you can get it from here.