Here is my code:
printf("preallocations\n");
char * addr = (char *) bo_gc320->m_fb_id[gc320_buf_idx];
cv::Mat src(cvSize(bo_gc320->m_width, bo_gc320->m_height), CV_8UC4, addr);
cv::Mat alpha(cvSize(bo_gc320->m_width, bo_gc320->m_height), CV_8UC1);
cv::Mat rgb(cvSize(bo_gc320->m_width, bo_gc320->m_height), CV_8UC3);
cv::Mat dst(cvSize(bo_gc320->m_width, bo_gc320->m_height), CV_8UC3);
printf("postallocations\n");
cv::Mat * out = new cv::Mat[4];// malloc(4*sizeof(cv::Mat *));
for (int k=0;k<4;k++) {
out[k] = cv::Mat(cvSize(bo_gc320->m_width, bo_gc320->m_height), CV_8UC1);
printInfo(out[k]);
}
printf("presplit\n");
printInfo(src);
cv::split(src, out);
printf("postsplit\n");
and the output is:
preallocations
postallocations
dim(332, 768)unsigned char(1)
dim(332, 768)unsigned char(1)
dim(332, 768)unsigned char(1)
dim(332, 768)unsigned char(1)
presplit
dim(332, 768)unsigned char(4)
Segmentation fault (core dumped)
I am printing the info about the arrays in a helper function. The data in addr is coming from the output buffer of a gc320 GPU. Could this be caused by the addr not containing valid data?
Turns out that addr was actually invalid data and was not filling the whole CV_8UC4 Mat struct. Once I changed the buffer, the problem was solved.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.